blob: 2a122b6077598487cbafb0969a618f3955ca61b4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
<?php
/**
* SCSSPHP
*
* @copyright 2012-2020 Leaf Corcoran
*
* @license http://opensource.org/licenses/MIT MIT
*
* @link http://scssphp.github.io/scssphp
*/
namespace ScssPhp\ScssPhp\Extend;
/**
* @template T of object
* @template-implements \IteratorAggregate<int, T>
*/
class ObjectSet implements \IteratorAggregate
{
/**
* @var \SplObjectStorage<T, mixed>
*/
private readonly \SplObjectStorage $storage;
public function __construct()
{
$this->storage = new \SplObjectStorage();
}
/**
* @param T $value
*/
public function contains(object $value): bool
{
return $this->storage->contains($value);
}
/**
* @param T $value
*/
public function add(object $value): void
{
$this->storage->attach($value);
}
/**
* @param ObjectSet<T> $set
*/
public function addAll(self $set): void
{
$this->storage->addAll($set->storage);
}
public function getIterator(): \Traversable
{
return $this->storage;
}
}
|