Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 6 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| FromMixedStorage | |
0.00% |
0 / 6 |
|
0.00% |
0 / 2 |
12 | |
0.00% |
0 / 1 |
| supports | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 | |||
| create | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | namespace Apie\StorageMetadata\ClassInstantiators; |
| 3 | |
| 4 | use Apie\Core\TypeUtils; |
| 5 | use Apie\StorageMetadata\Interfaces\ClassInstantiatorInterface; |
| 6 | use Apie\StorageMetadata\Interfaces\StorageDtoInterface; |
| 7 | use Apie\StorageMetadataBuilder\Interfaces\MixedStorageInterface; |
| 8 | use Apie\TypeConverter\ReflectionTypeFactory; |
| 9 | use ReflectionClass; |
| 10 | |
| 11 | final class FromMixedStorage implements ClassInstantiatorInterface |
| 12 | { |
| 13 | public function supports(ReflectionClass $class, ?StorageDtoInterface $storageObject = null): bool |
| 14 | { |
| 15 | return $storageObject instanceof MixedStorageInterface |
| 16 | && TypeUtils::matchesType( |
| 17 | ReflectionTypeFactory::createReflectionType($class->name), |
| 18 | $storageObject->toOriginalObject() |
| 19 | ); |
| 20 | } |
| 21 | |
| 22 | /** |
| 23 | * @param MixedStorageInterface&StorageDtoInterface $storageObject |
| 24 | */ |
| 25 | public function create(ReflectionClass $class, ?StorageDtoInterface $storageObject = null): object |
| 26 | { |
| 27 | return $storageObject->toOriginalObject(); |
| 28 | } |
| 29 | } |