Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
40.00% |
2 / 5 |
|
40.00% |
2 / 5 |
CRAP | |
0.00% |
0 / 1 |
| AliasStrategy | |
40.00% |
2 / 5 |
|
40.00% |
2 / 5 |
10.40 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| supports | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getCreationMetadata | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getModificationMetadata | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getResultMetadata | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Apie\Core\Metadata\Strategy; |
| 4 | |
| 5 | use Apie\Core\ApieLib; |
| 6 | use Apie\Core\Context\ApieContext; |
| 7 | use Apie\Core\Metadata\MetadataFactory; |
| 8 | use Apie\Core\Metadata\MetadataInterface; |
| 9 | use Apie\Core\Metadata\StrategyInterface; |
| 10 | use Apie\TypeConverter\ReflectionTypeFactory; |
| 11 | use ReflectionClass; |
| 12 | use ReflectionType; |
| 13 | |
| 14 | class AliasStrategy implements StrategyInterface |
| 15 | { |
| 16 | private readonly ReflectionType $type; |
| 17 | public function __construct(string $typehint) |
| 18 | { |
| 19 | $this->type = ReflectionTypeFactory::createReflectionType(ApieLib::getAlias($typehint)); |
| 20 | } |
| 21 | public static function supports(ReflectionClass $class): bool |
| 22 | { |
| 23 | return ApieLib::hasAlias($class->name); |
| 24 | } |
| 25 | |
| 26 | public function getCreationMetadata(ApieContext $context): MetadataInterface |
| 27 | { |
| 28 | return MetadataFactory::getCreationMetadata($this->type, $context); |
| 29 | } |
| 30 | |
| 31 | public function getModificationMetadata(ApieContext $context): MetadataInterface |
| 32 | { |
| 33 | return MetadataFactory::getModificationMetadata($this->type, $context); |
| 34 | } |
| 35 | |
| 36 | public function getResultMetadata(ApieContext $context): MetadataInterface |
| 37 | { |
| 38 | return MetadataFactory::getResultMetadata($this->type, $context); |
| 39 | } |
| 40 | } |