ArrayStore   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 92.86%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 32
ccs 13
cts 14
cp 0.9286
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 4 1
A set() 0 4 1
A increment() 0 7 2
A exists() 0 4 1
A storage() 0 4 1
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