@@ -35,7 +35,7 @@ use MyCLabs\Enum\Enum;
3535/**
3636 * Action enum
3737 */
38- class Action extends Enum
38+ final class Action extends Enum
3939{
4040 private const VIEW = 'view';
4141 private const EDIT = 'edit';
@@ -50,7 +50,7 @@ $action = Action::VIEW();
5050// or with a dynamic key:
5151$action = Action::$key();
5252// or with a dynamic value:
53- $action = new Action($value);
53+ $action = Action::from ($value);
5454```
5555
5656As you can see, static methods are automatically implemented to provide quick access to an enum value.
@@ -73,6 +73,7 @@ function setAction(Action $action) {
7373
7474Static methods:
7575
76+ - ` from() ` Creates an Enum instance, checking that the value exist in the enum
7677- ` toArray() ` method Returns all possible values as an array (constant name in key, constant value in value)
7778- ` keys() ` Returns the names (keys) of all constants in the Enum class
7879- ` values() ` Returns instances of the Enum class of all Enum constants (constant name in key, Enum instance in value)
@@ -83,7 +84,7 @@ Static methods:
8384### Static methods
8485
8586``` php
86- class Action extends Enum
87+ final class Action extends Enum
8788{
8889 private const VIEW = 'view';
8990 private const EDIT = 'edit';
@@ -99,7 +100,7 @@ Static method helpers are implemented using [`__callStatic()`](http://www.php.ne
99100If you care about IDE autocompletion, you can either implement the static methods yourself:
100101
101102``` php
102- class Action extends Enum
103+ final class Action extends Enum
103104{
104105 private const VIEW = 'view';
105106
@@ -119,7 +120,7 @@ or you can use phpdoc (this is supported in PhpStorm for example):
119120 * @method static Action VIEW()
120121 * @method static Action EDIT()
121122 */
122- class Action extends Enum
123+ final class Action extends Enum
123124{
124125 private const VIEW = 'view';
125126 private const EDIT = 'edit';
0 commit comments