Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
ReflectionPropertyToReflectionClassConverter
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 convert
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2namespace Apie\Core\TypeConverters;
3
4use Apie\TypeConverter\ConverterInterface;
5use Apie\TypeConverter\ReflectionTypeFactory;
6use Apie\TypeConverter\TypeConverter;
7use ReflectionClass;
8use ReflectionProperty;
9use ReflectionType;
10
11/**
12 * @implements ConverterInterface<ReflectionProperty, ReflectionClass>
13 */
14class 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}