Conditions | 7 |
Paths | 4 |
Total Lines | 14 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 2 |
CRAP Score | 13.125 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
52 | public function check($value): bool |
||
53 | { |
||
54 | if ($value instanceof $this->type) { |
||
55 | return true; |
||
56 | } |
||
57 | |||
58 | if (empty($value) || ! function_exists('enum_exists') || ! enum_exists($this->type) || ! method_exists($this->type, 'tryFrom')) { |
||
59 | 2 | return false; |
|
60 | } |
||
61 | |||
62 | try { |
||
63 | 2 | return null !== $this->type::tryFrom($value); |
|
64 | } catch (TypeError $e) { |
||
65 | return false; |
||
66 | } |
||
69 |