Skip to content

Commit 3aab1ee

Browse files
HP-1751 created PriceTypeDefinitionInterface
1 parent 38a2f4a commit 3aab1ee

11 files changed

+69
-25
lines changed

src/product/behavior/BehaviorCollection.php

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

55
use hiqdev\php\billing\product\Domain\Model\TariffTypeInterface;
66

7-
class BehaviorCollection implements BehaviorCollectionInterface
7+
abstract class BehaviorCollection implements BehaviorCollectionInterface
88
{
99
/** @var BehaviorInterface[] */
1010
private array $behaviors = [];

src/product/behavior/BehaviorCollectionInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ interface BehaviorCollectionInterface extends \IteratorAggregate
1010
public function getIterator(): \Traversable;
1111

1212
public function attach(BehaviorInterface $behavior): self;
13+
14+
public function end();
1315
}

src/product/behavior/BehaviorPriceTypeDefinitionCollection.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
namespace hiqdev\php\billing\product\behavior;
44

55
use hiqdev\php\billing\product\Domain\Model\TariffTypeInterface;
6-
use hiqdev\php\billing\product\price\PriceTypeDefinition;
6+
use hiqdev\php\billing\product\price\PriceTypeDefinitionInterface;
77

88
class BehaviorPriceTypeDefinitionCollection extends BehaviorCollection
99
{
10-
public function __construct(private readonly PriceTypeDefinition $parent, TariffTypeInterface $tariffType)
10+
public function __construct(private readonly PriceTypeDefinitionInterface $parent, TariffTypeInterface $tariffType)
1111
{
1212
parent::__construct($tariffType);
1313
}
1414

15-
public function end(): PriceTypeDefinition
15+
public function end(): PriceTypeDefinitionInterface
1616
{
1717
return $this->parent;
1818
}

src/product/behavior/BehaviorTariffTypeCollection.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
namespace hiqdev\php\billing\product\behavior;
44

55
use hiqdev\php\billing\product\Domain\Model\TariffTypeInterface;
6-
use hiqdev\php\billing\product\TariffTypeDefinition;
6+
use hiqdev\php\billing\product\TariffTypeDefinitionInterface;
77

88
class BehaviorTariffTypeCollection extends BehaviorCollection
99
{
10-
public function __construct(private readonly TariffTypeDefinition $parent, TariffTypeInterface $tariffType)
10+
public function __construct(private readonly TariffTypeDefinitionInterface $parent, TariffTypeInterface $tariffType)
1111
{
1212
parent::__construct($tariffType);
1313
}
1414

15-
public function end(): TariffTypeDefinition
15+
public function end(): TariffTypeDefinitionInterface
1616
{
1717
return $this->parent;
1818
}

src/product/price/PriceTypeDefinition.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use hiqdev\php\billing\product\Exception\AggregateNotDefinedException;
77
use hiqdev\php\billing\product\behavior\BehaviorPriceTypeDefinitionCollection;
88
use hiqdev\php\billing\product\invoice\InvoiceRepresentationCollection;
9-
use hiqdev\php\billing\product\behavior\HasBehaviorsInterface;
109
use hiqdev\php\billing\product\quantity\InvalidQuantityFormatterException;
1110
use hiqdev\php\billing\product\quantity\QuantityFormatterDefinition;
1211
use hiqdev\php\billing\product\quantity\QuantityFormatterFactory;
@@ -21,7 +20,7 @@
2120
* @template T of PriceTypeDefinitionCollectionInterface
2221
* @psalm-consistent-templates
2322
*/
24-
class PriceTypeDefinition implements HasBehaviorsInterface
23+
class PriceTypeDefinition implements PriceTypeDefinitionInterface
2524
{
2625
private UnitInterface $unit;
2726

@@ -90,9 +89,8 @@ public function quantityFormatter(string $formatterClass, $fractionUnit = null):
9089
return $this;
9190
}
9291

93-
public function createQuantityFormatter(
94-
FractionQuantityData $data,
95-
): QuantityFormatterInterface {
92+
public function createQuantityFormatter(FractionQuantityData $data): QuantityFormatterInterface
93+
{
9694
return QuantityFormatterFactory::create(
9795
$this->getUnit()->createExternalUnit(),
9896
$this->quantityFormatterDefinition,
@@ -154,11 +152,7 @@ public function hasBehavior(string $behaviorClassName): bool
154152
}
155153

156154
/**
157-
* це параметер визначає агрегатну функцію яка застосовується для щоденно записаних ресурсів щоб визнизначти
158-
* місячне споживання за яке потрібно пробілити клієнта
159-
*
160-
* @param AggregateInterface $aggregate
161-
* @return self
155+
* @inerhitDoc
162156
*/
163157
public function aggregation(AggregateInterface $aggregate): self
164158
{

src/product/price/PriceTypeDefinitionCollection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ public function __construct(
2626
}
2727

2828
/**
29-
* @return PriceTypeDefinition[]
29+
* @inerhitDoc
3030
*/
3131
public function getIterator(): \Traversable
3232
{
3333
return new \ArrayIterator($this->storage->getAll());
3434
}
3535

36-
public function priceType(TypeInterface $type): PriceTypeDefinition
36+
public function priceType(TypeInterface $type): PriceTypeDefinitionInterface
3737
{
3838
$priceType = $this->factory->create($this->collectionInstance, $type, $this->parent->tariffType());
3939
$this->storage->add($type, $priceType);

src/product/price/PriceTypeDefinitionCollectionInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
interface PriceTypeDefinitionCollectionInterface extends \IteratorAggregate, \Countable
99
{
1010
/**
11-
* @return PriceTypeDefinition[]
11+
* @return PriceTypeDefinitionInterface[]
1212
*/
1313
public function getIterator(): \Traversable;
1414

15-
public function priceType(TypeInterface $type): PriceTypeDefinition;
15+
public function priceType(TypeInterface $type): PriceTypeDefinitionInterface;
1616

1717
public function end(): TariffTypeDefinitionInterface;
1818
}

src/product/price/PriceTypeDefinitionFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public function create(
1111
PriceTypeDefinitionCollectionInterface $parent,
1212
TypeInterface $type,
1313
TariffTypeInterface $tariffType,
14-
): PriceTypeDefinition {
14+
): PriceTypeDefinitionInterface {
1515
return new PriceTypeDefinition($parent, $type, $tariffType);
1616
}
1717
}

src/product/price/PriceTypeDefinitionFactoryInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ public function create(
1111
PriceTypeDefinitionCollectionInterface $parent,
1212
TypeInterface $type,
1313
TariffTypeInterface $tariffType,
14-
): PriceTypeDefinition;
14+
): PriceTypeDefinitionInterface;
1515
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace hiqdev\php\billing\product\price;
4+
5+
use hiqdev\php\billing\product\AggregateInterface;
6+
use hiqdev\php\billing\product\behavior\HasBehaviorsInterface;
7+
use hiqdev\php\billing\product\Domain\Model\Unit\UnitInterface;
8+
use hiqdev\php\billing\product\invoice\InvoiceRepresentationCollection;
9+
use hiqdev\php\billing\product\quantity\FractionQuantityData;
10+
use hiqdev\php\billing\product\quantity\QuantityFormatterInterface;
11+
use hiqdev\php\billing\type\TypeInterface;
12+
13+
interface PriceTypeDefinitionInterface extends HasBehaviorsInterface
14+
{
15+
public function unit(UnitInterface $unit): self;
16+
17+
public function description(string $description): self;
18+
19+
public function getDescription(): string;
20+
21+
public function quantityFormatter(string $formatterClass, $fractionUnit = null): self;
22+
23+
public function createQuantityFormatter(FractionQuantityData $data): QuantityFormatterInterface;
24+
25+
public function end(): PriceTypeDefinitionCollectionInterface;
26+
27+
public function documentRepresentation(): InvoiceRepresentationCollection;
28+
29+
// TODO: Not sure if it will be needed at all
30+
public function measuredWith(\hiqdev\billing\registry\measure\RcpTrafCollector $param): self;
31+
32+
public function type(): TypeInterface;
33+
34+
public function hasType(TypeInterface $type): bool;
35+
36+
public function getUnit(): UnitInterface;
37+
38+
/**
39+
* це параметер визначає агрегатну функцію яка застосовується для щоденно записаних ресурсів щоб визнизначти
40+
* місячне споживання за яке потрібно пробілити клієнта
41+
*
42+
* @param AggregateInterface $aggregate
43+
* @return self
44+
*/
45+
public function aggregation(AggregateInterface $aggregate): self;
46+
47+
public function getAggregate(): AggregateInterface;
48+
}

0 commit comments

Comments
 (0)