@@ -45,10 +45,6 @@ It's an abstract class that needs to be extended to use it.
45
45
46
46
## The way of class constants
47
47
48
- * Requires validation on every use
49
- * Hard to extend the list of possible values
50
- * Hard to get a human readable name of a value
51
-
52
48
class User
53
49
{
54
50
const INACTIVE = 0;
@@ -82,11 +78,11 @@ It's an abstract class that needs to be extended to use it.
82
78
Default user status: 0
83
79
Changed user status: 1
84
80
85
- ## The way of php-enum:
81
+ * Requires validation on every use
82
+ * Hard to extend the list of possible values
83
+ * Hard to get a human readable name of a value
86
84
87
- * Validation will be already done on basic class ``` Mabe_Enum ```
88
- * Using type-hint makes arguments save
89
- * Human readable name of a value is simple accessable
85
+ ## The way of php-enum:
90
86
91
87
class UserStatusEnum extends Mabe_Enum
92
88
{
@@ -127,6 +123,10 @@ It's an abstract class that needs to be extended to use it.
127
123
Default user status: INACTIVE (0)
128
124
Changed user status: ACTIVE (1)
129
125
126
+ * Validation will be already done on basic class ``` Mabe_Enum ```
127
+ * Using type-hint makes arguments save
128
+ * Human readable name of a value is simple accessable
129
+
130
130
131
131
# Install
132
132
@@ -138,12 +138,14 @@ Add ```marc-mabe/php-enum``` to the project's composer.json dependencies and run
138
138
## GIT
139
139
140
140
``` git clone git://github.com/marc-mabe/php-enum.git ```
141
+
141
142
(The class ``` Mabe_Enum ``` will be located in ``` src/Mabe/Enum.php ``` )
142
143
143
144
## ZIP / TAR
144
145
145
146
Download the last version from [ Github] ( https://github.com/marc-mabe/php-enum/tags )
146
147
and extract it.
148
+
147
149
(The class ``` Mabe_Enum ``` will be located in ``` src/Mabe/Enum.php ``` )
148
150
149
151
@@ -169,14 +171,14 @@ constant values has ```NULL``` as value.
169
171
That's because ``` $value ``` was defined as ``` NULL ``` in the base class and
170
172
No constant assignable to the default value.
171
173
172
- * No argument on constructor results in an InvalidArgumentException
173
-
174
174
class MyEnumWithoutDefaultValue extends Mabe_Enum
175
175
{
176
176
const ONE = 1;
177
177
const TWO = 2;
178
178
}
179
179
180
+ * No argument on constructor results in an InvalidArgumentException
181
+
180
182
## Constant with NULL as value
181
183
182
184
Because ``` $value ``` property is defined as ``` NULL ``` a constant with
0 commit comments