Total Complexity | 6 |
Total Lines | 58 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
18 | class ParameterBag extends Data |
||
19 | { |
||
20 | /** |
||
21 | * Sets array of parameters. |
||
22 | * |
||
23 | * @param $parameters |
||
24 | */ |
||
25 | public function setParameters($parameters) |
||
26 | { |
||
27 | $this->data = $parameters; |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * Adds array of parameters. |
||
32 | * |
||
33 | * @param array $parameters |
||
34 | */ |
||
35 | public function addParameters(array $parameters) |
||
36 | { |
||
37 | $this->data = array_replace($this->data, $parameters); |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * Sets parameter with given name and value. |
||
42 | * |
||
43 | * @param int|string $name |
||
44 | * @param mixed $value |
||
45 | */ |
||
46 | public function setParameter($name, $value) |
||
47 | { |
||
48 | $this->data[$name] = $value; |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * Gets the parameter by its name. |
||
53 | * |
||
54 | * @param string $name |
||
55 | * @param mixed $default |
||
56 | * |
||
57 | * @return mixed |
||
58 | */ |
||
59 | public function getParameter($name, $default = null) |
||
60 | { |
||
61 | if (isset($this->data[$name])) { |
||
62 | return $this->data[$name]; |
||
63 | } |
||
64 | |||
65 | return parent::get($name, $default); |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * Gets all parameters. |
||
70 | * |
||
71 | * @return array |
||
72 | */ |
||
73 | public function toArray() |
||
76 | } |
||
77 | } |
||
78 |