1 | <?php |
||
17 | final class SourceCollection implements \Countable, \IteratorAggregate |
||
18 | { |
||
19 | /** |
||
20 | * @var SourceLocation[] |
||
21 | */ |
||
22 | private $sourceLocations = []; |
||
23 | |||
24 | /** |
||
25 | * @var Error[] |
||
26 | */ |
||
27 | private $errors = []; |
||
28 | |||
29 | /** |
||
30 | * {@inheritdoc} |
||
31 | */ |
||
32 | 2 | public function getIterator(): \Traversable |
|
33 | { |
||
34 | 2 | return new \ArrayIterator($this->sourceLocations); |
|
35 | } |
||
36 | |||
37 | /** |
||
38 | * {@inheritdoc} |
||
39 | */ |
||
40 | 32 | public function count(): int |
|
41 | { |
||
42 | 32 | return \count($this->sourceLocations); |
|
43 | } |
||
44 | |||
45 | 33 | public function addLocation(SourceLocation $location): void |
|
46 | { |
||
47 | 33 | $this->sourceLocations[] = $location; |
|
48 | 33 | } |
|
49 | |||
50 | 10 | public function addError(Error $error): void |
|
54 | |||
55 | 9 | public function first(): ?SourceLocation |
|
56 | { |
||
57 | 9 | if (empty($this->sourceLocations)) { |
|
63 | |||
64 | 21 | public function get(string $key): ?SourceLocation |
|
72 | |||
73 | 9 | public function getErrors(): array |
|
77 | } |
||
78 |