1 | <?php |
||
12 | abstract class Options |
||
13 | { |
||
14 | /** |
||
15 | * Check that all required options are defined, then hydrate. |
||
16 | * |
||
17 | * @param array $values |
||
18 | */ |
||
19 | 5 | final public function __construct(array $values) |
|
33 | |||
34 | /** |
||
35 | * Get a list of all required options. |
||
36 | * |
||
37 | * return [ |
||
38 | * 'email', |
||
39 | * 'password', |
||
40 | * ]; |
||
41 | * |
||
42 | * @return array |
||
43 | */ |
||
44 | abstract public function required(); |
||
45 | |||
46 | /** |
||
47 | * Get a list of all valid options. |
||
48 | * |
||
49 | * @return array |
||
50 | */ |
||
51 | 5 | public function valid() |
|
55 | |||
56 | /** |
||
57 | * Get all options as an array. |
||
58 | * |
||
59 | * @return array |
||
60 | */ |
||
61 | 5 | public function toArray() |
|
65 | |||
66 | /** |
||
67 | * Provide read-only access to attributes. |
||
68 | * |
||
69 | * @param string $key |
||
70 | * |
||
71 | * @return mixed |
||
72 | */ |
||
73 | 2 | final public function __get($key) |
|
77 | |||
78 | /** |
||
79 | * Prevent modification. |
||
80 | * |
||
81 | * @throws ImmutableException |
||
82 | * |
||
83 | * @param string $key |
||
84 | * @param mixed $value |
||
85 | * |
||
86 | * @return void |
||
87 | */ |
||
88 | 1 | final public function __set($key, $value) |
|
92 | |||
93 | /** |
||
94 | * Prevent modification. |
||
95 | * |
||
96 | * @throws ImmutableException |
||
97 | * |
||
98 | * @param string $key |
||
99 | * |
||
100 | * @return void |
||
101 | */ |
||
102 | 1 | final public function __unset($key) |
|
106 | |||
107 | /** |
||
108 | * Ensure that all required options are included in the given values. |
||
109 | * |
||
110 | * @param array $values |
||
111 | * |
||
112 | * @return void |
||
113 | * |
||
114 | * @throws CommandException |
||
115 | * If any required options have not been defined. |
||
116 | */ |
||
117 | private function ensureRequired(array $values) |
||
129 | } |
||
130 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.