Dummy::get()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
c 0
b 0
f 0
ccs 4
cts 4
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
crap 2
1
<?php
2
/**
3
 * AnimeDb package.
4
 *
5
 * @author    Peter Gribanov <[email protected]>
6
 * @copyright Copyright (c) 2014, Peter Gribanov
7
 * @license   http://opensource.org/licenses/MIT
8
 */
9
10
namespace AnimeDb\Bundle\CacheTimeKeeperBundle\Service\Driver;
11
12
class Dummy extends BaseDriver
13
{
14
    /**
15
     * @var array
16
     */
17
    protected $times = [];
18
19
    /**
20
     * @param string $key
21
     *
22
     * @return \DateTime|null
23
     */
24 4
    public function get($key)
25
    {
26 4
        if (isset($this->times[$key])) {
27 2
            return clone $this->times[$key];
28
        }
29
30 2
        return;
31
    }
32
33
    /**
34
     * @param string $key
35
     * @param \DateTime $time
36
     *
37
     * @return bool
38
     */
39 4
    public function set($key, \DateTime $time)
40
    {
41 4
        $this->times[$key] = clone $time;
42
43 4
        return true;
44
    }
45
46
    /**
47
     * @param string $key
48
     *
49
     * @return bool
50
     */
51 2
    public function remove($key)
52
    {
53 2
        if (isset($this->times[$key])) {
54 1
            unset($this->times[$key]);
55
56 1
            return true;
57
        }
58
59 1
        return false;
60
    }
61
}
62