1 | <?php namespace BuildR\Utils\Enumeration; |
||
20 | class EnumerationBase implements StringConvertibleInterface { |
||
21 | |||
22 | /** |
||
23 | * @type mixed |
||
24 | */ |
||
25 | public $value; |
||
26 | |||
27 | /** |
||
28 | * @type array |
||
29 | */ |
||
30 | private static $cache = []; |
||
31 | |||
32 | /** |
||
33 | * EnumerationBase constructor |
||
34 | * |
||
35 | * @param mixed $value |
||
36 | * |
||
37 | * @throws \BuildR\Utils\Enumeration\Exception\EnumerationException |
||
38 | */ |
||
39 | 18 | public function __construct($value) { |
|
46 | |||
47 | /** |
||
48 | * Determines that the current value in the enumeration is valid. |
||
49 | * |
||
50 | * @param mixed $value |
||
51 | * |
||
52 | * @return bool |
||
53 | */ |
||
54 | 18 | public function isValid($value) { |
|
57 | |||
58 | /** |
||
59 | * Returns the enumeration current value |
||
60 | * |
||
61 | * @return mixed |
||
62 | */ |
||
63 | 1 | public function getValue() { |
|
66 | |||
67 | /** |
||
68 | * Translate the current enumeration to an associative array |
||
69 | * |
||
70 | * @return array |
||
71 | */ |
||
72 | 18 | public static function toArray() { |
|
82 | |||
83 | /** |
||
84 | * Returns an indexed array that contains all key from this enumeration as value. |
||
85 | * |
||
86 | * @return array |
||
87 | */ |
||
88 | 1 | public static function getKeys() { |
|
91 | |||
92 | /** |
||
93 | * Determines that the given key is exist in the current enumeration or not. |
||
94 | * |
||
95 | * @param string $key |
||
96 | * |
||
97 | * @return bool |
||
98 | * |
||
99 | * @throws \BuildR\Utils\Enumeration\Exception\EnumerationException |
||
100 | */ |
||
101 | 7 | public static function isValidKey($key) { |
|
108 | |||
109 | /** |
||
110 | * Return the sie of the current enumeration |
||
111 | * |
||
112 | * @return int |
||
113 | */ |
||
114 | 1 | public static function size() { |
|
117 | |||
118 | /** |
||
119 | * This is a proxy method. This is called when the enumeration property called as a method. |
||
120 | * This method creates a new instance from the parent class with the value defined by |
||
121 | * the constant. |
||
122 | * |
||
123 | * @param string $name The constant name |
||
124 | * @param array $arguments This function not take any arguments |
||
125 | * |
||
126 | * @return object |
||
127 | */ |
||
128 | 18 | public static function __callStatic($name, $arguments) { |
|
142 | |||
143 | // ========================================== |
||
144 | // StringConvertibleInterface implementation |
||
145 | // ========================================== |
||
146 | |||
147 | /** |
||
148 | * {@inheritdoc} |
||
149 | */ |
||
150 | 1 | public function __toString() { |
|
153 | |||
154 | /** |
||
155 | * {@inheritdoc} |
||
156 | */ |
||
157 | public function toString() { |
||
160 | |||
161 | } |
||
162 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.