Total Complexity | 5 |
Total Lines | 45 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
15 | class RepresentationCollection implements IteratorAggregate, HasLockInterface |
||
16 | { |
||
17 | use HasLock; |
||
18 | |||
19 | private array $representations = []; |
||
20 | |||
21 | private RepresentationUniquenessGuard $uniquenessGuard; |
||
22 | |||
23 | public function __construct(private readonly PriceTypeDefinition $priceTypeDefinition) |
||
24 | { |
||
25 | $this->uniquenessGuard = new RepresentationUniquenessGuard(); |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * @return Traversable<int, RepresentationInterface> |
||
30 | */ |
||
31 | public function getIterator(): Traversable |
||
34 | } |
||
35 | |||
36 | public function attach(RepresentationInterface $representation): self |
||
37 | { |
||
38 | $this->ensureNotLocked(); |
||
39 | |||
40 | $representation->setType($this->priceTypeDefinition->type()); |
||
41 | |||
42 | $this->uniquenessGuard->ensureUnique($representation); |
||
43 | |||
44 | $this->representations[] = $representation; |
||
45 | |||
46 | return $this; |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * @psalm-return T |
||
51 | */ |
||
52 | public function end(): PriceTypeDefinition |
||
55 | } |
||
56 | |||
57 | public function filterByType(string $className): array |
||
62 |