Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| InvalidStringForValueObjectException | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | namespace Apie\Core\ValueObjects\Exceptions; |
| 3 | |
| 4 | use Apie\Core\Exceptions\ApieException; |
| 5 | use Apie\Core\ValueObjects\Interfaces\ValueObjectInterface; |
| 6 | use Apie\Core\ValueObjects\Utils; |
| 7 | use ReflectionClass; |
| 8 | use Throwable; |
| 9 | |
| 10 | /** |
| 11 | * Exception thrown by a value object that the input is not valid for a |
| 12 | * value object. |
| 13 | */ |
| 14 | class InvalidStringForValueObjectException extends ApieException |
| 15 | { |
| 16 | /** |
| 17 | * @param ValueObjectInterface|ReflectionClass<object> $valueObject |
| 18 | */ |
| 19 | public function __construct(string $input, ValueObjectInterface|ReflectionClass $valueObject, ?Throwable $previous = null) |
| 20 | { |
| 21 | parent::__construct( |
| 22 | sprintf( |
| 23 | 'Value "%s" is not valid for value object of type: %s', |
| 24 | $input, |
| 25 | Utils::getDisplayNameForValueObject($valueObject) |
| 26 | ), |
| 27 | 0, |
| 28 | $previous |
| 29 | ); |
| 30 | } |
| 31 | } |