1 | <?php |
||
12 | class Settings { |
||
13 | /** |
||
14 | * @var array Main storage for key-avlues in this collection. |
||
15 | */ |
||
16 | private $settings = array(); |
||
17 | |||
18 | /** |
||
19 | * Set a setting. |
||
20 | * |
||
21 | * @param mixed $key The key the value should be added under. |
||
22 | * @param mixed $value The value to be added to the key. |
||
23 | * |
||
24 | * @api |
||
25 | * @since future |
||
26 | * @return void |
||
27 | */ |
||
28 | 3 | public function set( $key, $value ) { |
|
31 | |||
32 | /** |
||
33 | * Set an setting. |
||
34 | * |
||
35 | * @param mixed $key The key in this setting to retrieve. |
||
36 | * @param mixed $default A default in case the key is not set. |
||
37 | * |
||
38 | * @api |
||
39 | * @since future |
||
40 | * @return mixed|null |
||
41 | */ |
||
42 | 1 | public function get( $key, $default = null ) { |
|
45 | |||
46 | /** |
||
47 | * Returns all the objects in this collection as an an array. |
||
48 | * |
||
49 | * @api |
||
50 | * @since future |
||
51 | * @return array The objects in this collection. |
||
52 | */ |
||
53 | 1 | public function all() { |
|
56 | } |
||
57 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.