File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -128,7 +128,7 @@ It's an abstract class that needs to be extended to use it.
128
128
Changed user status: ACTIVE (1)
129
129
130
130
131
- # Installation
131
+ # Install
132
132
133
133
## Composer
134
134
@@ -200,6 +200,21 @@ to a constant.
200
200
protected $value = -1;
201
201
}
202
202
203
+ ## Inheritance
204
+
205
+ It's also possible to extend other enumerations.
206
+
207
+ class MyEnum extends Mabe_Enum
208
+ {
209
+ const ONE = 1;
210
+ const TWO = 2;
211
+ }
212
+
213
+ class EnumInheritance extends MyEnum
214
+ {
215
+ const INHERITACE = 'Inheritance';
216
+ }
217
+
203
218
204
219
# New BSD License
205
220
Original file line number Diff line number Diff line change @@ -58,8 +58,17 @@ public function testEnumWithoutDefaultValue()
58
58
{
59
59
$ this ->setExpectedException ('InvalidArgumentException ' );
60
60
new EnumWithoutDefaultValue ();
61
+ }
62
+
63
+ public function testEnumInheritance ()
64
+ {
65
+ $ enum = new EnumInheritance (EnumInheritance::ONE );
66
+ $ this ->assertSame (EnumInheritance::ONE , $ enum ->getValue ());
67
+
68
+ $ enum = new EnumInheritance (EnumInheritance::INHERITACE );
69
+ $ this ->assertSame (EnumInheritance::INHERITACE , $ enum ->getValue ());
61
70
}
62
-
71
+
63
72
public function testChangeValueOnConstructor ()
64
73
{
65
74
$ enum = new EnumWithoutDefaultValue (1 );
@@ -119,5 +128,10 @@ class EnumWithoutDefaultValue extends Mabe_Enum
119
128
const TWO = 2 ;
120
129
}
121
130
131
+ class EnumInheritance extends EnumWithoutDefaultValue
132
+ {
133
+ const INHERITACE = 'Inheritance ' ;
134
+ }
135
+
122
136
class EmptyEnum extends Mabe_Enum
123
137
{}
You can’t perform that action at this time.
0 commit comments