1 | <?php |
||
18 | abstract class AbstractEnum implements EnumInterface, IteratorAggregate |
||
19 | { |
||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | private $value; |
||
24 | |||
25 | /** |
||
26 | * Constructor |
||
27 | * |
||
28 | * @param string $value |
||
29 | */ |
||
30 | public function __construct($value) |
||
38 | |||
39 | /** |
||
40 | * Return the value as a string |
||
41 | * |
||
42 | * @return string |
||
43 | */ |
||
44 | public function __toString() |
||
48 | |||
49 | /** |
||
50 | * Do a comparison to check if the enums are non-strictly equal |
||
51 | * |
||
52 | * @param AbstractEnum $enum |
||
53 | * @return bool |
||
54 | */ |
||
55 | public function equals(AbstractEnum $enum) |
||
59 | |||
60 | /** |
||
61 | * Create a new instance of the enum |
||
62 | * |
||
63 | * @param string $value |
||
64 | * @return $this |
||
65 | */ |
||
66 | public static function create($value) |
||
70 | |||
71 | /** |
||
72 | * Return true if the value is valid for the enum |
||
73 | * |
||
74 | * @param string $value |
||
75 | * @return bool |
||
76 | */ |
||
77 | public static function exists($value) |
||
81 | |||
82 | /** |
||
83 | * Get an array of the enum values |
||
84 | * |
||
85 | * @return array |
||
86 | */ |
||
87 | public static function values() |
||
91 | |||
92 | /** |
||
93 | * Return enum as an array with keys matching values |
||
94 | * |
||
95 | * @return array |
||
96 | */ |
||
97 | public static function toArray() |
||
101 | |||
102 | /** |
||
103 | * Get the current enum value |
||
104 | * |
||
105 | * @return string |
||
106 | */ |
||
107 | public function getValue() |
||
111 | |||
112 | /** |
||
113 | * Return the values to be used in a loop |
||
114 | * |
||
115 | * @return array |
||
116 | */ |
||
117 | public function getIterator() |
||
121 | } |
||
122 |