Skip to content

Commit afe5a62

Browse files
HP-1751 Removed dependency php-billing package from InvoiceRepresentationCollection and RepresentationInterface classes
1 parent 285ae11 commit afe5a62

File tree

4 files changed

+57
-2
lines changed

4 files changed

+57
-2
lines changed

src/product/BillingRegistry.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace hiqdev\php\billing\product;
44

5-
use hiqdev\billing\registry\invoice\RepresentationInterface;
5+
use hiqdev\php\billing\product\invoice\RepresentationInterface;
66
use hiqdev\php\billing\product\quantity\QuantityFormatterNotFoundException;
77
use hiqdev\php\billing\product\quantity\FractionQuantityData;
88
use hiqdev\php\billing\product\behavior\BehaviorInterface;

src/product/PriceTypeDefinition.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace hiqdev\php\billing\product;
44

55
use hiqdev\php\billing\product\behavior\BehaviourPriceTypeDefinitionCollection;
6-
use hiqdev\billing\registry\invoice\InvoiceRepresentationCollection;
6+
use hiqdev\php\billing\product\invoice\InvoiceRepresentationCollection;
77
use hiqdev\php\billing\product\quantity\QuantityFormatterDefinition;
88
use hiqdev\php\billing\product\quantity\QuantityFormatterFactory;
99
use hiqdev\php\billing\product\quantity\FractionQuantityData;
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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+
}

0 commit comments

Comments
 (0)