Skip to content

Commit 4ce2b38

Browse files
HP-1751 created AggregateNotDefinedException
1 parent c00ea1e commit 4ce2b38

6 files changed

+32
-12
lines changed

src/Exception/LogicException.php

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace hiqdev\php\billing\Exception;
4+
5+
class LogicException extends \LogicException
6+
{
7+
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace hiqdev\php\billing\product;
4+
5+
use hiqdev\php\billing\Exception\LogicException;
6+
7+
class AggregateNotDefinedException extends LogicException
8+
{
9+
10+
}
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace hiqdev\php\billing\product;
4+
5+
use hiqdev\php\billing\Exception\LogicException;
6+
7+
class ProductNotDefinedException extends LogicException
8+
{
9+
10+
}

src/product/ProductNotSetException.php

-10
This file was deleted.

src/product/TariffTypeDefinition.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function ofProduct(ProductInterface $product): TariffTypeDefinitionInterf
3636
public function getProduct(): ProductInterface
3737
{
3838
if ($this->product === null) {
39-
throw new ProductNotSetException('Product is not set');
39+
throw new ProductNotDefinedException('Product is not set. Call the ofProduct() method first.');
4040
}
4141

4242
return $this->product;

src/product/price/PriceTypeDefinition.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace hiqdev\php\billing\product\price;
44

55
use hiqdev\php\billing\product\AggregateInterface;
6+
use hiqdev\php\billing\product\AggregateNotDefinedException;
67
use hiqdev\php\billing\product\behavior\BehaviorPriceTypeDefinitionCollection;
78
use hiqdev\php\billing\product\invoice\InvoiceRepresentationCollection;
89
use hiqdev\php\billing\product\ParentNodeDefinitionInterface;
@@ -32,7 +33,7 @@ class PriceTypeDefinition implements ParentNodeDefinitionInterface
3233

3334
private BehaviorPriceTypeDefinitionCollection $behaviorCollection;
3435

35-
private AggregateInterface $aggregate;
36+
private ?AggregateInterface $aggregate = null;
3637

3738
public function __construct(
3839
/**
@@ -76,6 +77,7 @@ public function getDescription(): string
7677
* @param string $formatterClass
7778
* @param null|FractionUnitInterface|string $fractionUnit
7879
* @return $this
80+
* @throws InvalidQuantityFormatterException
7981
*/
8082
public function quantityFormatter(string $formatterClass, $fractionUnit = null): self
8183
{

0 commit comments

Comments
 (0)