1 | <?php |
||
10 | class Collection extends Configuration implements ArrayAccess |
||
11 | { |
||
12 | /** |
||
13 | * @param array|Configuration $config |
||
14 | * @return Collection |
||
15 | */ |
||
16 | public static function factory($config) |
||
21 | |||
22 | /** |
||
23 | * @var array |
||
24 | */ |
||
25 | private $container = []; |
||
26 | |||
27 | /** |
||
28 | * Set a config |
||
29 | * |
||
30 | * @param string $name |
||
31 | * @param array $config |
||
32 | * @return $this |
||
33 | */ |
||
34 | public function set($name, $config) |
||
43 | |||
44 | /** |
||
45 | * @param string $name |
||
46 | */ |
||
47 | public function remove($name) |
||
51 | |||
52 | /** |
||
53 | * Get a config |
||
54 | * |
||
55 | * @param string $name |
||
56 | * @param mixed $default |
||
57 | * @throws InvalidArgumentException |
||
58 | * @return mixed |
||
59 | */ |
||
60 | public function get($name, $default = null) |
||
78 | |||
79 | /** |
||
80 | * @return $this |
||
81 | */ |
||
82 | public function reset() |
||
87 | |||
88 | /** |
||
89 | * @param string $name |
||
90 | * @return mixed |
||
91 | */ |
||
92 | public function __get($name) |
||
96 | |||
97 | /** |
||
98 | * @param string $name |
||
99 | * @param array|null $args |
||
100 | * @return mixed |
||
101 | */ |
||
102 | public function __call($name, $args = null) |
||
106 | |||
107 | /** |
||
108 | * @param string $name |
||
109 | * @return bool |
||
110 | */ |
||
111 | public function __isset($name) |
||
115 | |||
116 | /** |
||
117 | * @param int $offset |
||
118 | * @return bool |
||
119 | */ |
||
120 | public function offsetExists($offset) |
||
125 | |||
126 | /** |
||
127 | * @param int $offset |
||
128 | * @return mixed |
||
129 | */ |
||
130 | public function offsetGet($offset) |
||
134 | |||
135 | /** |
||
136 | * @param int $offset |
||
137 | * @param mixed $value |
||
138 | */ |
||
139 | public function offsetSet($offset, $value) |
||
143 | |||
144 | /** |
||
145 | * @param int $offset |
||
146 | */ |
||
147 | public function offsetUnset($offset) |
||
151 | } |
||
152 |
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.