| 1 | <?php |
||
| 20 | class Options |
||
| 21 | { |
||
| 22 | /** |
||
| 23 | * Options constructor. |
||
| 24 | * |
||
| 25 | * @param array $options |
||
| 26 | */ |
||
| 27 | 26 | public function __construct(array $options) |
|
| 31 | |||
| 32 | /** |
||
| 33 | * Return a option value. |
||
| 34 | * |
||
| 35 | * @param string $name |
||
| 36 | * @param mixed $default |
||
| 37 | * @return mixed |
||
| 38 | */ |
||
| 39 | 6 | public function get($name, $default = null) |
|
| 43 | |||
| 44 | /** |
||
| 45 | * Return all options. |
||
| 46 | * |
||
| 47 | * @return array |
||
| 48 | */ |
||
| 49 | 8 | public function getAll() |
|
| 53 | } |
||
| 54 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: