Params   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
eloc 10
c 1
b 0
f 0
dl 0
loc 57
ccs 14
cts 14
cp 1
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A offsetUnset() 0 3 1
A setParamsData() 0 4 1
A offsetExists() 0 3 1
A offsetSet() 0 3 1
A offsetGet() 0 4 2
A getParamsData() 0 3 1
1
<?php
2
3
namespace kalanis\kw_address_handler;
4
5
6
use ArrayAccess;
7
8
9
/**
10
 * Class Params
11
 * @package kalanis\kw_address_handler\Sources
12
 * Class for accessing params inside the address as array
13
 * Not ArrayIterator due memory consumption
14
 * @implements ArrayAccess<string|int, string>
15
 */
16
class Params implements ArrayAccess
17
{
18
    /** @var array<string|int, string> */
19
    protected array $paramsData = [];
20
21
    /**
22
     * @param array<string|int, string> $data
23
     * @return $this
24
     */
25 8
    public function setParamsData(array $data): self
26
    {
27 8
        $this->paramsData = $data;
28 8
        return $this;
29
    }
30
31
    /**
32
     * @return array<string|int, string>
33
     */
34 7
    public function getParamsData(): array
35
    {
36 7
        return $this->paramsData;
37
    }
38
39
    /**
40
     * @param string|int $offset
41
     * @return bool
42
     */
43 7
    public function offsetExists($offset): bool
44
    {
45 7
        return isset($this->paramsData[$offset]);
46
    }
47
48
    /**
49
     * @param string|int $offset
50
     * @return string|null
51
     */
52
    #[\ReturnTypeWillChange]
53 6
    public function offsetGet($offset)
54
    {
55 6
        return $this->offsetExists($offset) ? $this->paramsData[$offset] : null;
56
    }
57
58
    /**
59
     * @param string|int $offset
60
     * @param string $value
61
     */
62 7
    public function offsetSet($offset, $value): void
63
    {
64 7
        $this->paramsData[$offset] = strval($value);
65 7
    }
66
67
    /**
68
     * @param string|int $offset
69
     */
70 2
    public function offsetUnset($offset): void
71
    {
72 2
        unset($this->paramsData[$offset]);
73 2
    }
74
}
75