Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
5 / 5 |
|
100.00% |
5 / 5 |
CRAP | |
100.00% |
1 / 1 |
EnumStrategy | |
100.00% |
5 / 5 |
|
100.00% |
5 / 5 |
5 | |
100.00% |
1 / 1 |
supports | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getCreationMetadata | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getModificationMetadata | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getResultMetadata | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | namespace Apie\Core\Metadata\Strategy; |
3 | |
4 | use Apie\Core\Context\ApieContext; |
5 | use Apie\Core\Metadata\EnumMetadata; |
6 | use Apie\Core\Metadata\StrategyInterface; |
7 | use ReflectionClass; |
8 | use ReflectionEnum; |
9 | use UnitEnum; |
10 | |
11 | final class EnumStrategy implements StrategyInterface |
12 | { |
13 | /** @var ReflectionEnum<UnitEnum> $enum */ |
14 | private ReflectionEnum $enum; |
15 | |
16 | public static function supports(ReflectionClass $class): bool |
17 | { |
18 | return $class->isEnum(); |
19 | } |
20 | |
21 | /** |
22 | * @param ReflectionClass<UnitEnum> $class |
23 | */ |
24 | public function __construct(ReflectionClass $class) |
25 | { |
26 | $this->enum = new ReflectionEnum($class->name); |
27 | } |
28 | |
29 | public function getCreationMetadata(ApieContext $context): EnumMetadata |
30 | { |
31 | return new EnumMetadata($this->enum); |
32 | } |
33 | |
34 | public function getModificationMetadata(ApieContext $context): EnumMetadata |
35 | { |
36 | return new EnumMetadata($this->enum); |
37 | } |
38 | |
39 | public function getResultMetadata(ApieContext $context): EnumMetadata |
40 | { |
41 | return new EnumMetadata($this->enum); |
42 | } |
43 | } |