Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
3 / 3 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| IsStringValueObjectExample | |
100.00% |
3 / 3 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
| convert | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| validate | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | namespace Apie\Fixtures\ValueObjects; |
| 3 | |
| 4 | use Apie\Core\Attributes\Description; |
| 5 | use Apie\Core\ValueObjects\Exceptions\InvalidStringForValueObjectException; |
| 6 | use Apie\Core\ValueObjects\Interfaces\ValueObjectInterface; |
| 7 | use Apie\Core\ValueObjects\IsStringValueObject; |
| 8 | use ReflectionClass; |
| 9 | |
| 10 | #[Description("An example class of a string value.")] |
| 11 | class IsStringValueObjectExample implements ValueObjectInterface |
| 12 | { |
| 13 | use IsStringValueObject; |
| 14 | |
| 15 | protected function convert(string $input): string |
| 16 | { |
| 17 | return trim($input); |
| 18 | } |
| 19 | |
| 20 | public static function validate(string $input): void |
| 21 | { |
| 22 | if (empty($input)) { |
| 23 | throw new InvalidStringForValueObjectException($input, new ReflectionClass(self::class)); |
| 24 | } |
| 25 | } |
| 26 | } |