@@ -6,70 +6,70 @@ |
||
6 | 6 | |
7 | 7 | class BaseEnum |
8 | 8 | { |
9 | - /** |
|
10 | - * Get all constants as an array. |
|
11 | - * |
|
12 | - * @return array |
|
13 | - */ |
|
14 | - public static function all() |
|
15 | - { |
|
16 | - return (new ReflectionClass(get_called_class()))->getConstants(); |
|
17 | - } |
|
9 | + /** |
|
10 | + * Get all constants as an array. |
|
11 | + * |
|
12 | + * @return array |
|
13 | + */ |
|
14 | + public static function all() |
|
15 | + { |
|
16 | + return (new ReflectionClass(get_called_class()))->getConstants(); |
|
17 | + } |
|
18 | 18 | |
19 | - /** |
|
20 | - * Get all constants values as an array. |
|
21 | - * |
|
22 | - * @return array |
|
23 | - */ |
|
24 | - public static function values() |
|
25 | - { |
|
26 | - return array_values(self::all()); |
|
27 | - } |
|
19 | + /** |
|
20 | + * Get all constants values as an array. |
|
21 | + * |
|
22 | + * @return array |
|
23 | + */ |
|
24 | + public static function values() |
|
25 | + { |
|
26 | + return array_values(self::all()); |
|
27 | + } |
|
28 | 28 | |
29 | - /** |
|
30 | - * Get constant value for the given key. |
|
31 | - * |
|
32 | - * @param string $key |
|
33 | - * @return array |
|
34 | - */ |
|
35 | - public static function value($key) |
|
36 | - { |
|
37 | - return collect(self::all())->get($key); |
|
38 | - } |
|
29 | + /** |
|
30 | + * Get constant value for the given key. |
|
31 | + * |
|
32 | + * @param string $key |
|
33 | + * @return array |
|
34 | + */ |
|
35 | + public static function value($key) |
|
36 | + { |
|
37 | + return collect(self::all())->get($key); |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * Get all constants keys as an array. |
|
42 | - * |
|
43 | - * @return array |
|
44 | - */ |
|
45 | - public static function keys() |
|
46 | - { |
|
47 | - return array_keys(self::all()); |
|
48 | - } |
|
40 | + /** |
|
41 | + * Get all constants keys as an array. |
|
42 | + * |
|
43 | + * @return array |
|
44 | + */ |
|
45 | + public static function keys() |
|
46 | + { |
|
47 | + return array_keys(self::all()); |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * Get constant key for the given value. |
|
52 | - * |
|
53 | - * @param string $value |
|
54 | - * @return mixed |
|
55 | - */ |
|
56 | - public static function key($value) |
|
57 | - { |
|
58 | - return collect(self::all())->search($value); |
|
59 | - } |
|
50 | + /** |
|
51 | + * Get constant key for the given value. |
|
52 | + * |
|
53 | + * @param string $value |
|
54 | + * @return mixed |
|
55 | + */ |
|
56 | + public static function key($value) |
|
57 | + { |
|
58 | + return collect(self::all())->search($value); |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * Convert the consts to key: value comma seperated string. |
|
63 | - * |
|
64 | - * @return string |
|
65 | - */ |
|
66 | - public static function toString() |
|
67 | - { |
|
68 | - $stringArr = []; |
|
69 | - collect(self::all())->each(function($item, $key) use (&$stringArr) { |
|
70 | - $stringArr[] = $key . ': ' . $item; |
|
71 | - }); |
|
61 | + /** |
|
62 | + * Convert the consts to key: value comma seperated string. |
|
63 | + * |
|
64 | + * @return string |
|
65 | + */ |
|
66 | + public static function toString() |
|
67 | + { |
|
68 | + $stringArr = []; |
|
69 | + collect(self::all())->each(function($item, $key) use (&$stringArr) { |
|
70 | + $stringArr[] = $key . ': ' . $item; |
|
71 | + }); |
|
72 | 72 | |
73 | - return implode(',', $stringArr); |
|
74 | - } |
|
73 | + return implode(',', $stringArr); |
|
74 | + } |
|
75 | 75 | } |