1 | <?php |
||
17 | class ParamBag implements \ArrayAccess, \IteratorAggregate |
||
18 | { |
||
19 | /** |
||
20 | * @var array |
||
21 | */ |
||
22 | protected $params = []; |
||
23 | |||
24 | /** |
||
25 | * Create a new parameter bag instance. |
||
26 | * |
||
27 | * @param array $params |
||
28 | * |
||
29 | * @return void |
||
30 | */ |
||
31 | 43 | public function __construct(array $params) |
|
35 | |||
36 | /** |
||
37 | * Get parameter values out of the bag. |
||
38 | * |
||
39 | * @param string $key |
||
40 | * |
||
41 | * @return mixed |
||
42 | */ |
||
43 | 2 | public function get($key) |
|
47 | |||
48 | /** |
||
49 | * Get parameter values out of the bag via the property access magic method. |
||
50 | * |
||
51 | * @param string $key |
||
52 | * |
||
53 | * @return mixed |
||
54 | */ |
||
55 | 5 | public function __get($key) |
|
59 | |||
60 | /** |
||
61 | * Check if a param exists in the bag via an isset() check on the property. |
||
62 | * |
||
63 | * @param string $key |
||
64 | * |
||
65 | * @return bool |
||
66 | */ |
||
67 | 2 | public function __isset($key) |
|
71 | |||
72 | /** |
||
73 | * Disallow changing the value of params in the data bag via property access. |
||
74 | * |
||
75 | * @param string $key |
||
76 | * @param mixed $value |
||
77 | * |
||
78 | * @throws \LogicException |
||
79 | * |
||
80 | * @return void |
||
81 | */ |
||
82 | 1 | public function __set($key, $value) |
|
86 | |||
87 | /** |
||
88 | * Disallow unsetting params in the data bag via property access. |
||
89 | * |
||
90 | * @param string $key |
||
91 | * |
||
92 | * @throws \LogicException |
||
93 | * |
||
94 | * @return void |
||
95 | */ |
||
96 | 1 | public function __unset($key) |
|
100 | |||
101 | /** |
||
102 | * Check if a param exists in the bag via an isset() and array access. |
||
103 | * |
||
104 | * @param string $key |
||
105 | * |
||
106 | * @return bool |
||
107 | */ |
||
108 | 1 | public function offsetExists($key) |
|
112 | |||
113 | /** |
||
114 | * Get parameter values out of the bag via array access. |
||
115 | * |
||
116 | * @param string $key |
||
117 | * |
||
118 | * @return mixed |
||
119 | */ |
||
120 | 2 | public function offsetGet($key) |
|
124 | |||
125 | /** |
||
126 | * Disallow changing the value of params in the data bag via array access. |
||
127 | * |
||
128 | * @param string $key |
||
129 | * @param mixed $value |
||
130 | * |
||
131 | * @throws \LogicException |
||
132 | * |
||
133 | * @return void |
||
134 | */ |
||
135 | 1 | public function offsetSet($key, $value) |
|
139 | |||
140 | /** |
||
141 | * Disallow unsetting params in the data bag via array access. |
||
142 | * |
||
143 | * @param string $key |
||
144 | * |
||
145 | * @throws \LogicException |
||
146 | * |
||
147 | * @return void |
||
148 | */ |
||
149 | 1 | public function offsetUnset($key) |
|
153 | |||
154 | /** |
||
155 | * IteratorAggregate for iterating over the object like an array. |
||
156 | * |
||
157 | * @return \ArrayIterator |
||
158 | */ |
||
159 | 10 | public function getIterator() |
|
163 | } |
||
164 |