ArrayStore::set()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Tequilarapido\TrackIt\Store;
4
5
class ArrayStore implements Store
6
{
7
    protected $storage = [];
8
9 6
    public function get($key)
10
    {
11 6
        return array_get($this->storage, $key);
12
    }
13
14 7
    public function set($key, $value)
15
    {
16 7
        $this->storage[$key] = $value;
17 7
    }
18
19 3
    public function increment($key, $increment = 1)
20
    {
21 3
        if (! array_key_exists($key, $this->storage)) {
22
            $this->storage[$key] = 0;
23
        }
24 3
        $this->storage[$key] = $this->storage[$key] + $increment;
25 3
    }
26
27 1
    public function exists($key)
28
    {
29 1
        return (bool) array_key_exists($key, $this->storage);
30
    }
31
32 1
    public function storage()
33
    {
34 1
        return $this->storage;
35
    }
36
}
37