File tree Expand file tree Collapse file tree 4 files changed +57
-2
lines changed
Expand file tree Collapse file tree 4 files changed +57
-2
lines changed Original file line number Diff line number Diff line change 22
33namespace hiqdev \php \billing \product ;
44
5- use hiqdev \billing \registry \invoice \RepresentationInterface ;
5+ use hiqdev \php \ billing \product \invoice \RepresentationInterface ;
66use hiqdev \php \billing \product \quantity \QuantityFormatterNotFoundException ;
77use hiqdev \php \billing \product \quantity \FractionQuantityData ;
88use hiqdev \php \billing \product \behavior \BehaviorInterface ;
Original file line number Diff line number Diff line change 33namespace hiqdev \php \billing \product ;
44
55use hiqdev \php \billing \product \behavior \BehaviourPriceTypeDefinitionCollection ;
6- use hiqdev \billing \registry \invoice \InvoiceRepresentationCollection ;
6+ use hiqdev \php \ billing \product \invoice \InvoiceRepresentationCollection ;
77use hiqdev \php \billing \product \quantity \QuantityFormatterDefinition ;
88use hiqdev \php \billing \product \quantity \QuantityFormatterFactory ;
99use hiqdev \php \billing \product \quantity \FractionQuantityData ;
Original file line number Diff line number Diff line change 1+ <?php declare (strict_types=1 );
2+
3+ namespace hiqdev \php \billing \product \invoice ;
4+
5+ use hiqdev \php \billing \product \PriceTypeDefinition ;
6+
7+ class InvoiceRepresentationCollection implements \IteratorAggregate
8+ {
9+ private array $ representations = [];
10+
11+ public function __construct (private readonly PriceTypeDefinition $ priceTypeDefinition )
12+ {
13+ }
14+
15+ /**
16+ * @return RepresentationInterface[]
17+ */
18+ public function getIterator (): \Traversable
19+ {
20+ return new \ArrayIterator ($ this ->representations );
21+ }
22+
23+ public function attach (RepresentationInterface $ representation ): self
24+ {
25+ $ representation ->setType ($ this ->priceTypeDefinition ->type ());
26+
27+ $ this ->representations [] = $ representation ;
28+
29+ return $ this ;
30+ }
31+
32+ public function end (): PriceTypeDefinition
33+ {
34+ return $ this ->priceTypeDefinition ;
35+ }
36+
37+ public function filterByType (string $ className ): array
38+ {
39+ return array_filter ($ this ->representations , fn ($ r ) => $ r instanceof $ className );
40+ }
41+ }
Original file line number Diff line number Diff line change 1+ <?php declare (strict_types=1 );
2+
3+ namespace hiqdev \php \billing \product \invoice ;
4+
5+ use hiqdev \php \billing \type \TypeInterface ;
6+
7+ interface RepresentationInterface
8+ {
9+ public function getSql (): string ;
10+
11+ public function getType (): TypeInterface ;
12+
13+ public function setType (TypeInterface $ type ): void ;
14+ }
You can’t perform that action at this time.
0 commit comments