Test Failed
Pull Request — master (#18)
by Alex
02:31
created

ImmutableParameters   A

Complexity

Total Complexity 17

Size/Duplication

Total Lines 157
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 17
eloc 14
c 1
b 0
f 0
dl 0
loc 157
rs 10

17 Methods

Rating   Name   Duplication   Size   Complexity  
A hasParam() 0 3 1
A offsetExists() 0 3 1
A __construct() 0 3 1
A getParam() 0 3 1
A count() 0 3 1
A isEmpty() 0 3 1
A removeParams() 0 2 1
A setParam() 0 2 1
A removeParam() 0 4 1
A getParams() 0 3 1
A offsetSet() 0 2 1
A setParams() 0 2 1
A getKeys() 0 3 1
A offsetGet() 0 3 1
A getValues() 0 3 1
A offsetUnset() 0 2 1
A getIterator() 0 3 1
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