Skip to content

Commit 9b25ddf

Browse files
HP-1751 created InvalidRepresentationException
1 parent 75ee687 commit 9b25ddf

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/product/BillingRegistry.php

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

55
use hiqdev\php\billing\product\behavior\InvalidBehaviorException;
6+
use hiqdev\php\billing\product\invoice\InvalidRepresentationException;
67
use hiqdev\php\billing\product\invoice\RepresentationInterface;
78
use hiqdev\php\billing\product\price\PriceTypeDefinition;
89
use hiqdev\php\billing\product\quantity\QuantityFormatterNotFoundException;
@@ -47,6 +48,10 @@ public function priceTypes(): \Generator
4748
*/
4849
public function getRepresentationsByType(string $representationClass): array
4950
{
51+
if (!class_exists($representationClass)) {
52+
throw new InvalidRepresentationException("Class '$representationClass' does not exist");
53+
}
54+
5055
$representations = [];
5156
foreach ($this->priceTypes() as $priceTypeDefinition) {
5257
foreach ($priceTypeDefinition->documentRepresentation() as $representation) {
Lines changed: 10 additions & 0 deletions
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\invoice;
4+
5+
use InvalidArgumentException;
6+
7+
class InvalidRepresentationException extends InvalidArgumentException
8+
{
9+
10+
}

0 commit comments

Comments
 (0)