1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Arp\EventDispatcher\Event; |
6
|
|
|
|
7
|
|
|
use Exception; |
8
|
|
|
use Traversable; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* A parameters collection that is closed for modifications |
12
|
|
|
* |
13
|
|
|
* @author Alex Patterson <[email protected]> |
14
|
|
|
* @package Arp\EventDispatcher\Event |
15
|
|
|
*/ |
16
|
|
|
final class ImmutableParameters implements ParametersInterface |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @var ParametersInterface |
20
|
|
|
*/ |
21
|
|
|
private ParametersInterface $parameters; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @param ParametersInterface $parameters |
25
|
|
|
*/ |
26
|
|
|
public function __construct(ParametersInterface $parameters) |
27
|
|
|
{ |
28
|
|
|
$this->parameters = $parameters; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @return int |
33
|
|
|
*/ |
34
|
|
|
public function count(): int |
35
|
|
|
{ |
36
|
|
|
return $this->parameters->count(); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @return bool |
41
|
|
|
*/ |
42
|
|
|
public function isEmpty(): bool |
43
|
|
|
{ |
44
|
|
|
return $this->parameters->isEmpty(); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @param string $name |
50
|
|
|
* |
51
|
|
|
* @return bool |
52
|
|
|
*/ |
53
|
|
|
public function hasParam(string $name): bool |
54
|
|
|
{ |
55
|
|
|
return $this->parameters->hasParam($name); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @param string $name |
60
|
|
|
* @param mixed $default |
61
|
|
|
* |
62
|
|
|
* @return mixed |
63
|
|
|
*/ |
64
|
|
|
public function getParam(string $name, $default = null) |
65
|
|
|
{ |
66
|
|
|
return $this->parameters->getParam($name, $default); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @return array<mixed> |
71
|
|
|
*/ |
72
|
|
|
public function getParams(): array |
73
|
|
|
{ |
74
|
|
|
return $this->parameters->getParams(); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @param array<mixed> $params |
79
|
|
|
*/ |
80
|
|
|
public function setParams(array $params): void |
81
|
|
|
{ |
82
|
|
|
// Ignore any updates to parameters to respect immutability |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @param string $name |
87
|
|
|
* @param mixed $value |
88
|
|
|
*/ |
89
|
|
|
public function setParam(string $name, $value): void |
90
|
|
|
{ |
91
|
|
|
// Ignore any updates to parameters to respect immutability |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @param array<mixed> $params |
96
|
|
|
*/ |
97
|
|
|
public function removeParams(array $params = []): void |
98
|
|
|
{ |
99
|
|
|
// Ignore any updates to parameters to respect immutability |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @param string $name |
104
|
|
|
* |
105
|
|
|
* @return bool |
106
|
|
|
*/ |
107
|
|
|
public function removeParam(string $name): bool |
108
|
|
|
{ |
109
|
|
|
// Ignore any updates to parameters to respect immutability |
110
|
|
|
return false; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @return array<int, mixed> |
115
|
|
|
*/ |
116
|
|
|
public function getKeys(): array |
117
|
|
|
{ |
118
|
|
|
return $this->parameters->getKeys(); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @return array<mixed> |
123
|
|
|
*/ |
124
|
|
|
public function getValues(): array |
125
|
|
|
{ |
126
|
|
|
return $this->parameters->getValues(); |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @return Traversable<mixed> |
131
|
|
|
* |
132
|
|
|
* @throws Exception |
133
|
|
|
*/ |
134
|
|
|
public function getIterator(): \Traversable |
135
|
|
|
{ |
136
|
|
|
return $this->parameters->getIterator(); |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @param mixed $offset |
141
|
|
|
* |
142
|
|
|
* @return bool |
143
|
|
|
*/ |
144
|
|
|
public function offsetExists($offset): bool |
145
|
|
|
{ |
146
|
|
|
return $this->parameters->offsetExists($offset); |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* @param mixed $offset |
151
|
|
|
* |
152
|
|
|
* @return mixed |
153
|
|
|
*/ |
154
|
|
|
public function offsetGet($offset) |
155
|
|
|
{ |
156
|
|
|
return $this->parameters->offsetGet($offset); |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
/** |
160
|
|
|
* @param mixed $offset |
161
|
|
|
* @param mixed $value |
162
|
|
|
*/ |
163
|
|
|
public function offsetSet($offset, $value): void |
164
|
|
|
{ |
165
|
|
|
// Ignore any updates to parameters to respect immutability |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
/** |
169
|
|
|
* @param mixed $offset |
170
|
|
|
*/ |
171
|
|
|
public function offsetUnset($offset): void |
172
|
|
|
{ |
173
|
|
|
// Ignore any updates to parameters to respect immutability |
174
|
|
|
} |
175
|
|
|
} |
176
|
|
|
|