ArrayCacheDriver::add()   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
cc 1
eloc 2
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 MidasSoft\DominicanBankParser\Cache;
4
5
class ArrayCacheDriver extends AbstractCacheDriver
6
{
7
    /**
8
     * The data container.
9
     *
10
     * @var array
11
     */
12
    protected $data;
13
14
    /**
15
     * Adds a new value to the cache.
16
     *
17
     * @param string $key
18
     * @param mixed  $value
19
     *
20
     * @return void
21
     */
22 11
    public function add($key, $value)
23
    {
24 11
        $this->data[$key] = serialize($value);
25 11
        $this->keys[] = $key;
26 11
    }
27
28
    /**
29
     * Recovers a value from the cache.
30
     *
31
     * @param string $key
32
     *
33
     * @return mixed
34
     */
35 5
    public function get($key)
36
    {
37 5
        return unserialize($this->data[$key]);
38
    }
39
40
    /**
41
     * Returns the data property.
42
     *
43
     * @var array
44
     */
45 2
    public function getData()
46
    {
47 2
        return $this->data;
48
    }
49
50
    /**
51
     * Removes a value from the cache.
52
     *
53
     * @param string $key
54
     *
55
     * @return void
56
     */
57 1
    public function remove($key)
58
    {
59 1
        unset($this->data[$key]);
60 1
    }
61
}
62