Passed
Branch dev_2x (3e8772)
by Adrian
01:42
created

Base   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 8
c 0
b 0
f 0
dl 0
loc 35
rs 10
1
<?php
2
declare(strict_types=1);
3
4
namespace Sirius\Orm\Blueprint;
5
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
    }
42
}
43