1 | <?php |
||
13 | class Enum extends Int |
||
14 | { |
||
15 | /** |
||
16 | * @var array Array of possible values. Keys should by integer. |
||
17 | */ |
||
18 | protected $values; |
||
19 | |||
20 | /** |
||
21 | * @var mixed Default value, if no one of possible values are not relate to read value. |
||
22 | */ |
||
23 | protected $default; |
||
24 | |||
25 | 6 | public function __construct($size, array $values = [], $options = []) |
|
32 | |||
33 | /** |
||
34 | * Read key from Stream, and return value by this key or default value. |
||
35 | * |
||
36 | * @param AbstractStream $stream Stream from which resolved field reads. |
||
37 | * @return object|integer|double|string|array|boolean|callable Value by read key or default value if present. |
||
38 | * @throws InvalidKeyException If read key is not exist and default value is not presented. |
||
39 | */ |
||
40 | 4 | public function read(AbstractStream $stream) |
|
60 | |||
61 | /** |
||
62 | * @return array |
||
63 | */ |
||
64 | 4 | public function getValues() |
|
68 | |||
69 | /** |
||
70 | * @param array $values |
||
71 | */ |
||
72 | 5 | public function setValues($values) |
|
76 | |||
77 | /** |
||
78 | * @return mixed |
||
79 | */ |
||
80 | 2 | public function getDefault() |
|
84 | |||
85 | /** |
||
86 | * @param mixed $default |
||
87 | */ |
||
88 | 2 | public function setDefault($default) |
|
92 | } |