Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
69.23% |
9 / 13 |
|
81.82% |
9 / 11 |
CRAP | |
0.00% |
0 / 1 |
StaticDiscriminatorColumn | |
69.23% |
9 / 13 |
|
81.82% |
9 / 11 |
14.52 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getValue | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getValueForClass | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getOptions | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
allowsNull | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
isRequired | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
isField | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
appliesToContext | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getTypehint | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getFieldPriority | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getAttributes | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | namespace Apie\Core\Metadata\Fields; |
3 | |
4 | use Apie\Core\Context\ApieContext; |
5 | use Apie\Core\Entities\PolymorphicEntityInterface; |
6 | use Apie\Core\Metadata\GetterInterface; |
7 | use Apie\TypeConverter\ReflectionTypeFactory; |
8 | use ReflectionClass; |
9 | use ReflectionType; |
10 | |
11 | class StaticDiscriminatorColumn implements FieldInterface, GetterInterface |
12 | { |
13 | public function __construct(private string $value) |
14 | { |
15 | } |
16 | |
17 | public function getValue(object $object, ApieContext $apieContext): mixed |
18 | { |
19 | return $this->value; |
20 | } |
21 | |
22 | /** |
23 | * @param ReflectionClass<PolymorphicEntityInterface> $class |
24 | */ |
25 | public function getValueForClass(ReflectionClass $class): string |
26 | { |
27 | return $this->value; |
28 | } |
29 | |
30 | /** @return array<string, string> */ |
31 | public function getOptions(ApieContext $apieContext, bool $runtimeFilter = false): array |
32 | { |
33 | return [ |
34 | $this->value => $this->value, |
35 | ]; |
36 | } |
37 | |
38 | public function allowsNull(): bool |
39 | { |
40 | return false; |
41 | } |
42 | |
43 | public function isRequired(): bool |
44 | { |
45 | return true; |
46 | } |
47 | |
48 | public function isField(): bool |
49 | { |
50 | return true; |
51 | } |
52 | |
53 | public function appliesToContext(ApieContext $apieContext): bool |
54 | { |
55 | return true; |
56 | } |
57 | |
58 | public function getTypehint(): ?ReflectionType |
59 | { |
60 | return ReflectionTypeFactory::createReflectionType('string'); |
61 | } |
62 | |
63 | public function getFieldPriority(): int |
64 | { |
65 | return -280; |
66 | } |
67 | |
68 | public function getAttributes(string $attributeClass, bool $classDocBlock = true, bool $propertyDocblock = true, bool $argumentDocBlock = true): array |
69 | { |
70 | return []; |
71 | } |
72 | } |