Test Failed
Pull Request — master (#40)
by Бабичев
03:32
created

ProxyService::offsetExists()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Bavix\Wallet\Services;
4
5
class ProxyService implements \ArrayAccess
6
{
7
8
    /**
9
     * @var array
10
     */
11
    protected $data = [];
12
13
    /**
14
     * @param string $key
15
     * @return bool
16
     */
17
    public function has(string $key): bool
18
    {
19
        return $this->offsetExists($key);
20
    }
21
22
    /**
23
     * @inheritDoc
24
     */
25
    public function offsetExists($offset): bool
26
    {
27
        return \array_key_exists($offset, $this->data);
28
    }
29
30
    /**
31
     * @param string $key
32
     * @return int
33
     */
34
    public function get(string $key): int
35
    {
36
        return $this->offsetGet($key);
37
    }
38
39
    /**
40
     * @inheritDoc
41
     */
42
    public function offsetGet($offset): int
43
    {
44
        return $this->data[$offset] ?? 0;
45
    }
46
47
    /**
48
     * @param string $key
49
     * @param int $value
50
     * @return static
51
     */
52
    public function set(string $key, int $value): self
53
    {
54
        $this->offsetSet($key, $value);
55
        return $this;
56
    }
57
58
    /**
59
     * @inheritDoc
60
     */
61
    public function offsetSet($offset, $value): void
62
    {
63
        $this->data[$offset] = $value;
64
    }
65
66
    /**
67
     * @param string $key
68
     * @return static
69
     */
70
    public function remove(string $key): self
71
    {
72
        $this->offsetUnset($key);
73
        return $this;
74
    }
75
76
    /**
77
     * @inheritDoc
78
     */
79
    public function offsetUnset($offset): void
80
    {
81
        unset($this->data[$offset]);
82
    }
83
84
    /**
85
     * @return void
86
     */
87
    public function fresh(): void
88
    {
89
        $this->data = [];
90
    }
91
92
}
93