Skip to content

Commit 90cb9a7

Browse files
committed
Update README.md
1 parent a0972a6 commit 90cb9a7

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

README.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
### Example
22

3-
## The const way
3+
## The way normal class constants
44

55
class User
66
{
@@ -30,11 +30,15 @@
3030
$user->setStatus(User::ACTIVE);
3131
echo 'Changed user status: ' . $user->getStatus() . PHP_EOL;
3232

33-
PRINTS:
34-
Default user status: 0
35-
Changed user status: 1
33+
PRINTS:
34+
Default user status: 0
35+
Changed user status: 1
3636

37-
## The Enum way:
37+
* Requires validation on every argument
38+
* Hard to extend the list of possible values
39+
* Hard to get the name of a value
40+
41+
## The way of enumerables:
3842

3943
class UserStatusEnum extends Enum
4044
{
@@ -70,10 +74,13 @@ Changed user status: 1
7074
$user->setStatus(new UserStatusEnum(UserStatusEnum::ACTIVE));
7175
echo 'Changed user status: ' . $user->getStatus() . '(' . $user->getStatus()->getValue() . ')' . PHP_EOL;
7276

73-
PRINTS:
74-
efault user status: INACTIVE (0)
75-
hanged user status: ACTIVE (1)
77+
PRINTS:
78+
Default user status: INACTIVE (0)
79+
Changed user status: ACTIVE (1)
7680

81+
* Validation already done on basic enum
82+
* Using type-hint makes argumets save
83+
* Name of value simple accessable
7784

7885
### New BSD License
7986

0 commit comments

Comments
 (0)