Ram   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A set() 0 5 1
A get() 0 4 2
A has() 0 4 1
A remove() 0 5 1
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