ArrayAdapter::delete()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
namespace Genkgo\Cache\Adapter;
3
4
use Genkgo\Cache\CacheAdapterInterface;
5
6
/**
7
 * Class ArrayAdapter
8
 * @package Genkgo\Cache\Adapter
9
 */
10
class ArrayAdapter implements CacheAdapterInterface
11
{
12
    /**
13
     * @var array
14
     */
15
    private $data = [];
16
17
    /**
18
     * @param $key
19
     * @param $value
20
     */
21 2
    public function set($key, $value)
22
    {
23 2
        $this->data[$key] = $value;
24 2
    }
25
26
    /**
27
     * @param $key
28
     * @return null|mixed
29
     */
30 3
    public function get($key)
31
    {
32 3
        if ($this->exists($key)) {
33 2
            return $this->data[$key];
34
        }
35 2
        return null;
36
    }
37
38
    /**
39
     * @param $key
40
     */
41 1
    public function delete($key)
42
    {
43 1
        unset($this->data[$key]);
44 1
    }
45
46
    /**
47
     * @param $key
48
     * @return bool
49
     */
50 3
    private function exists($key)
51
    {
52 3
        return isset($this->data[$key]) || array_key_exists($key, $this->data);
53
    }
54
}
55