1 | <?php |
||
8 | class ParamsBag implements Iterator, ArrayAccess |
||
9 | { |
||
10 | /** |
||
11 | * The array of option values. |
||
12 | * |
||
13 | * @var array |
||
14 | */ |
||
15 | private $params = array(); |
||
16 | |||
17 | 18 | public function __construct(array $params = array()) |
|
21 | |||
22 | 8 | public function get($name, $default = null) |
|
23 | { |
||
24 | 8 | return $this->offsetExists($name) |
|
25 | ? $this->offsetGet($name) |
||
26 | 8 | : $default; |
|
27 | } |
||
28 | |||
29 | 1 | public function __get($name) |
|
33 | |||
34 | public function __set($name, $value) |
||
38 | |||
39 | public function __isset($name) |
||
43 | |||
44 | /** |
||
45 | * Returns an array from params. |
||
46 | * |
||
47 | * @return array |
||
48 | */ |
||
49 | public function getArrayCopy() |
||
53 | |||
54 | /** |
||
55 | * {@inheritdoc} |
||
56 | */ |
||
57 | public function rewind() |
||
61 | |||
62 | /** |
||
63 | * {@inheritdoc} |
||
64 | */ |
||
65 | public function current() |
||
69 | |||
70 | /** |
||
71 | * {@inheritdoc} |
||
72 | */ |
||
73 | public function key() |
||
77 | |||
78 | /** |
||
79 | * {@inheritdoc} |
||
80 | */ |
||
81 | public function next() |
||
85 | |||
86 | /** |
||
87 | * {@inheritdoc} |
||
88 | */ |
||
89 | public function valid() |
||
93 | |||
94 | /** |
||
95 | * {@inheritdoc} |
||
96 | */ |
||
97 | public function offsetSet($offset, $value) |
||
98 | { |
||
99 | if (is_null($offset)) { |
||
100 | $this->params[] = $value; |
||
101 | } else { |
||
102 | $this->params[$offset] = $value; |
||
103 | } |
||
104 | } |
||
105 | |||
106 | /** |
||
107 | * {@inheritdoc} |
||
108 | */ |
||
109 | 8 | public function offsetExists($offset) |
|
113 | |||
114 | /** |
||
115 | * {@inheritdoc} |
||
116 | */ |
||
117 | public function offsetUnset($offset) |
||
121 | |||
122 | /** |
||
123 | * {@inheritdoc} |
||
124 | */ |
||
125 | 1 | public function offsetGet($offset) |
|
137 | } |
||
138 |