1 | <?php |
||
16 | abstract class EnumAbstract |
||
|
|||
17 | { |
||
18 | /** |
||
19 | * @var array |
||
20 | */ |
||
21 | protected static $cache = []; |
||
22 | |||
23 | /** |
||
24 | * @return array |
||
25 | */ |
||
26 | 146 | public static function toArray() |
|
27 | { |
||
28 | 146 | $class = get_called_class(); |
|
29 | 146 | if (!array_key_exists($class, static::$cache)) { |
|
30 | 1 | $reflection = new \ReflectionClass($class); |
|
31 | 1 | static::$cache[$class] = $reflection->getConstants(); |
|
32 | } |
||
33 | |||
34 | 146 | return static::$cache[$class]; |
|
35 | } |
||
36 | |||
37 | /** |
||
38 | * @return array |
||
39 | */ |
||
40 | 8 | public static function getKeys() |
|
44 | |||
45 | /** |
||
46 | * @param mixed $value |
||
47 | * |
||
48 | * @throws \InvalidArgumentException |
||
49 | * @return string |
||
50 | */ |
||
51 | public static function getKey($value) |
||
57 | |||
58 | /** |
||
59 | * @param string $key |
||
60 | * |
||
61 | * @return bool |
||
62 | */ |
||
63 | 32 | public static function isValidKey($key) |
|
67 | |||
68 | /** |
||
69 | * @param string $key |
||
70 | * |
||
71 | * @throws \InvalidArgumentException |
||
72 | */ |
||
73 | 32 | public static function assertIsValidKey($key) |
|
79 | |||
80 | /** |
||
81 | * @param string $key |
||
82 | * |
||
83 | * @throws \InvalidArgumentException |
||
84 | * @return mixed |
||
85 | */ |
||
86 | public static function getValue($key) |
||
92 | |||
93 | /** |
||
94 | * @return array |
||
95 | */ |
||
96 | 8 | public static function getValues() |
|
100 | |||
101 | /** |
||
102 | * @param mixed $value |
||
103 | * |
||
104 | * @return bool |
||
105 | */ |
||
106 | 90 | public static function isValidValue($value) |
|
110 | |||
111 | /** |
||
112 | * @throws \InvalidArgumentException |
||
113 | * |
||
114 | * @param mixed $value |
||
115 | */ |
||
116 | 90 | public static function assertIsValidValue($value) |
|
122 | } |
||
123 |
This check examines a number of code elements and verifies that they conform to the given naming conventions.
You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.