Total Complexity | 10 |
Total Lines | 62 |
Duplicated Lines | 0 % |
Coverage | 84.21% |
Changes | 0 |
1 | <?php |
||
7 | final class ParameterBag extends Bag |
||
8 | { |
||
9 | /** |
||
10 | * |
||
11 | * @param array $data |
||
12 | */ |
||
13 | 30 | public function __construct(array $data = []) |
|
14 | { |
||
15 | 30 | foreach ($data as $key => $value) { |
|
16 | 21 | $this->add($key, $value); |
|
17 | } |
||
18 | 28 | } |
|
19 | |||
20 | /** |
||
21 | * |
||
22 | * @param mixed $key |
||
23 | * @return bool |
||
24 | */ |
||
25 | 2 | public function has($key): bool |
|
28 | } |
||
29 | |||
30 | /** |
||
31 | * |
||
32 | * @param mixed $key |
||
33 | * @return mixed |
||
34 | */ |
||
35 | 1 | public function get($key) |
|
42 | } |
||
43 | |||
44 | /** |
||
45 | * |
||
46 | * @param mixed $key |
||
47 | * @param mixed $value |
||
48 | */ |
||
49 | 21 | public function add($key, $value) |
|
50 | { |
||
51 | 21 | if (!is_string($key)) { |
|
52 | 1 | throw new \RuntimeException('The key must be a string'); |
|
53 | } |
||
54 | |||
55 | 21 | if (!is_scalar($value) and !is_null($value)) { |
|
56 | 1 | throw new \RuntimeException(sprintf('The "%s" value must be a scalar or null', $key)); |
|
57 | } |
||
58 | |||
59 | 21 | $this->data[$key] = $value; |
|
60 | 21 | } |
|
61 | |||
62 | /** |
||
63 | * |
||
64 | * @param mixed $key |
||
65 | */ |
||
66 | public function remove($key) |
||
69 | } |
||
70 | } |
||
71 |