Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
3 / 3 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| ValueObjectDisplayProvider | |
100.00% |
3 / 3 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
| supports | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
| createComponentFor | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | namespace Apie\HtmlBuilders\FieldDisplayProviders; |
| 3 | |
| 4 | use Apie\Core\Utils\ValueObjectUtils; |
| 5 | use Apie\Core\ValueObjects\Interfaces\ValueObjectInterface; |
| 6 | use Apie\HtmlBuilders\FieldDisplayBuildContext; |
| 7 | use Apie\HtmlBuilders\Interfaces\ComponentInterface; |
| 8 | use Apie\HtmlBuilders\Interfaces\FieldDisplayComponentProviderInterface; |
| 9 | use ReflectionClass; |
| 10 | |
| 11 | final class ValueObjectDisplayProvider implements FieldDisplayComponentProviderInterface |
| 12 | { |
| 13 | public function supports(mixed $object, FieldDisplayBuildContext $context): bool |
| 14 | { |
| 15 | return $object instanceof ValueObjectInterface && ValueObjectUtils::isNonCompositeValueObject(new ReflectionClass($object)); |
| 16 | } |
| 17 | public function createComponentFor(mixed $object, FieldDisplayBuildContext $context): ComponentInterface |
| 18 | { |
| 19 | assert($object instanceof ValueObjectInterface); |
| 20 | return $context->createComponentFor($object->toNative()); |
| 21 | } |
| 22 | } |