Skip to content

Commit bd0ca51

Browse files
committed
Inheritance
1 parent 71e87c0 commit bd0ca51

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ It's an abstract class that needs to be extended to use it.
128128
Changed user status: ACTIVE (1)
129129

130130

131-
# Installation
131+
# Install
132132

133133
## Composer
134134

@@ -200,6 +200,21 @@ to a constant.
200200
protected $value = -1;
201201
}
202202

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+
203218

204219
# New BSD License
205220

tests/MabeTest/EnumTest.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,17 @@ public function testEnumWithoutDefaultValue()
5858
{
5959
$this->setExpectedException('InvalidArgumentException');
6060
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());
6170
}
62-
71+
6372
public function testChangeValueOnConstructor()
6473
{
6574
$enum = new EnumWithoutDefaultValue(1);
@@ -119,5 +128,10 @@ class EnumWithoutDefaultValue extends Mabe_Enum
119128
const TWO = 2;
120129
}
121130

131+
class EnumInheritance extends EnumWithoutDefaultValue
132+
{
133+
const INHERITACE = 'Inheritance';
134+
}
135+
122136
class EmptyEnum extends Mabe_Enum
123137
{}

0 commit comments

Comments
 (0)