Total Complexity | 5 |
Total Lines | 35 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
6 | abstract class Base |
||
7 | { |
||
8 | public function isValid() |
||
9 | { |
||
10 | return count($this->getErrors()) === 0; |
||
11 | } |
||
12 | |||
13 | public function getErrors(): array |
||
14 | { |
||
15 | return []; |
||
16 | } |
||
17 | |||
18 | /** |
||
19 | * These are observer instances that will make changes to the |
||
20 | * code being generated |
||
21 | * |
||
22 | * @return array |
||
23 | */ |
||
24 | public function getObservers(): array |
||
25 | { |
||
26 | return []; |
||
27 | } |
||
28 | |||
29 | protected function getClassConstants() |
||
30 | { |
||
31 | $reflect = new \ReflectionClass(get_class($this)); |
||
32 | |||
33 | return $reflect->getConstants(); |
||
34 | } |
||
35 | |||
36 | public function getConstantByValue($val) |
||
37 | { |
||
38 | $constants = array_reverse($this->getClassConstants()); |
||
39 | |||
40 | return $constants[$val] ?? null; |
||
41 | } |
||
43 |