Skip to content

Commit 995bd3a

Browse files
committed
updated README example and noted that FLOAT is a valid constant name
1 parent c0d9730 commit 995bd3a

File tree

3 files changed

+32
-23
lines changed

3 files changed

+32
-23
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ It's an abstract class that needs to be extended to use it.
2323
> particular concrete representation in the computer's memory; compilers and
2424
> interpreters can represent them arbitrarily.
2525
26+
2627
# Usage
2728

2829
## Basics
@@ -35,6 +36,13 @@ It's an abstract class that needs to be extended to use it.
3536
const INACTIVE = 0;
3637
const ACTIVE = 1;
3738
const DELETED = 2;
39+
40+
// all scalar datatypes are supported
41+
const NIL = null;
42+
const BOOLEAN = true;
43+
const INT = 1234;
44+
const STR = 'string';
45+
const FLOAT = 0.123;
3846
}
3947

4048
// different ways to instantiate an enumeration
@@ -129,6 +137,7 @@ Internally it's based of a list (array) of ordinal values.
129137
// iterate
130138
var_dump(iterator_to_array($enumSet)); // array(0 => UserStatus{$value=1});
131139

140+
132141
# Why not ```SplEnum```
133142

134143
* ```SplEnum``` is not build-in into PHP and requires pecl extension installed.

tests/MabeEnumTest/EnumTest.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,23 @@ public function testEnumInheritance()
3939
{
4040
$enum = EnumInheritance::get(EnumInheritance::ONE);
4141
$this->assertSame(array(
42-
'ONE' => 1,
43-
'TWO' => 2,
44-
'THREE' => 3,
45-
'FOUR' => 4,
46-
'FIVE' => 5,
47-
'SIX' => 6,
48-
'SEVEN' => 7,
49-
'EIGHT' => 8,
50-
'NINE' => 9,
51-
'ZERO' => 0,
52-
'FLOATING_POINT_NUMBER' => 0.123,
53-
'STR' => 'str',
54-
'STR_EMPTY' => '',
55-
'NIL' => null,
56-
'BOOLEAN_TRUE' => true,
57-
'BOOLEAN_FALSE' => false,
58-
'INHERITANCE' => 'Inheritance',
42+
'ONE' => 1,
43+
'TWO' => 2,
44+
'THREE' => 3,
45+
'FOUR' => 4,
46+
'FIVE' => 5,
47+
'SIX' => 6,
48+
'SEVEN' => 7,
49+
'EIGHT' => 8,
50+
'NINE' => 9,
51+
'ZERO' => 0,
52+
'FLOAT' => 0.123,
53+
'STR' => 'str',
54+
'STR_EMPTY' => '',
55+
'NIL' => null,
56+
'BOOLEAN_TRUE' => true,
57+
'BOOLEAN_FALSE' => false,
58+
'INHERITANCE' => 'Inheritance',
5959
), $enum::getConstants());
6060
$this->assertSame(EnumInheritance::ONE, $enum->getValue());
6161
$this->assertSame(0, $enum->getOrdinal());

tests/MabeEnumTest/TestAsset/EnumBasic.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ class EnumBasic extends Enum
2424
const NINE = 9;
2525
const ZERO = 0;
2626

27-
const FLOATING_POINT_NUMBER = 0.123;
28-
const STR = 'str';
29-
const STR_EMPTY = '';
30-
const NIL = null;
31-
const BOOLEAN_TRUE = true;
32-
const BOOLEAN_FALSE = false;
27+
const FLOAT = 0.123;
28+
const STR = 'str';
29+
const STR_EMPTY = '';
30+
const NIL = null;
31+
const BOOLEAN_TRUE = true;
32+
const BOOLEAN_FALSE = false;
3333
}

0 commit comments

Comments
 (0)