Conditions | 5 |
Paths | 4 |
Total Lines | 21 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 5 |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
17 | 5 | public function supports($value): bool |
|
18 | { |
||
19 | 5 | if (!\is_string($value)) { |
|
20 | 1 | return false; |
|
21 | } |
||
22 | |||
23 | 4 | $matches = []; |
|
24 | |||
25 | 4 | if (0 === preg_match($this->pattern, $value, $matches)) { |
|
26 | 1 | return false; |
|
27 | } |
||
28 | |||
29 | 3 | if (!class_exists($matches['class']) && !interface_exists($matches['class'])) { |
|
30 | 1 | return false; |
|
31 | } |
||
32 | |||
33 | 2 | $constants = (new ReflectionClass($matches['class'])) |
|
34 | 2 | ->getConstants() |
|
35 | ; |
||
36 | |||
37 | 2 | return \array_key_exists($matches['constant'], $constants); |
|
38 | } |
||
51 |