Ram::__construct()   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 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
namespace FMUP\Cache\Driver;
3
4
use FMUP\Cache\CacheInterface;
5
6
class Ram implements CacheInterface
7
{
8
    protected $params = array();
9
10
    /**
11
     * constructor of Ram
12
     * @param array $params
13
     */
14 5
    public function __construct($params = array())
15
    {
16 5
        $this->params = $params;
17 5
    }
18
19
    /**
20
     * set a param
21
     * @param string $key
22
     * @param mixed $value
23
     * @return \FMUP\Cache\Driver\Ram
24
     */
25 2
    public function set($key, $value)
26
    {
27 2
        $this->params[$key] = $value;
28 2
        return $this;
29
    }
30
31
    /**
32
     * get a param
33
     * @param string $key
34
     * @return mixed|null
35
     */
36 2
    public function get($key)
37
    {
38 2
        return $this->has($key) ? $this->params[$key] : null;
39
    }
40
41
    /**
42
     * has a param
43
     * @param string $key
44
     * @return bool
45
     */
46 6
    public function has($key)
47
    {
48 6
        return array_key_exists($key, $this->params);
49
    }
50
51
    /**
52
     * remove a param in object
53
     * @param string $key
54
     * @return \FMUP\Cache\Driver\Ram
55
     */
56 2
    public function remove($key)
57
    {
58 2
        unset($this->params[$key]);
59 2
        return $this;
60
    }
61
}
62