Passed
Pull Request — master (#18)
by Alex
06:24 queued 03:24
created

ImmutableParameters   A

Complexity

Total Complexity 17

Size/Duplication

Total Lines 157
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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