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

ImmutableParameters::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 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