Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| ReflectionPropertyToReflectionClassConverter | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| convert | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | namespace Apie\Core\TypeConverters; |
| 3 | |
| 4 | use Apie\TypeConverter\ConverterInterface; |
| 5 | use Apie\TypeConverter\ReflectionTypeFactory; |
| 6 | use Apie\TypeConverter\TypeConverter; |
| 7 | use ReflectionClass; |
| 8 | use ReflectionProperty; |
| 9 | use ReflectionType; |
| 10 | |
| 11 | /** |
| 12 | * @implements ConverterInterface<ReflectionProperty, ReflectionClass> |
| 13 | */ |
| 14 | class ReflectionPropertyToReflectionClassConverter implements ConverterInterface |
| 15 | { |
| 16 | /** |
| 17 | * @return ReflectionClass<object>|null |
| 18 | */ |
| 19 | public function convert(ReflectionProperty $input, ?ReflectionType $wantedType = null, ?TypeConverter $converter = null): ?ReflectionClass |
| 20 | { |
| 21 | $wantedType ??= ReflectionTypeFactory::createReflectionType('ReflectionClass'); |
| 22 | return $converter->convertTo( |
| 23 | $input->getType() ?? ReflectionTypeFactory::createReflectionType('mixed'), |
| 24 | $wantedType |
| 25 | ); |
| 26 | } |
| 27 | } |