Completed
Push — master ( a1970e...6c5d6a )
by Oleg
04:15
created

ArrayDriver::getMeta()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
1
<?php /** MicroArrayCache */
2
3
namespace Micro\Cache\Drivers;
4
5
use Micro\File\Type;
6
7
/**
8
 * Class ArrayDriver
9
 *
10
 * @author Oleg Lunegov <[email protected]>
11
 * @link https://github.com/linpax/microphp-framework
12
 * @copyright Copyright (c) 2013 Oleg Lunegov
13
 * @license https://github.com/linpax/microphp-framework/blob/master/LICENSE
14
 * @package Micro
15
 * @subpackage Cache\Driver
16
 * @version 1.0
17
 * @since 1.0
18
 */
19
class ArrayDriver extends CacheDriver
20
{
21
    /** @var array $driver array as driver */
22
    protected $driver = [];
23
24
25
    /**
26
     * @inheritdoc
27
     */
28
    public function check()
29
    {
30
        return true;
31
    }
32
33
    /**
34
     * @inheritdoc
35
     */
36
    public function get($name)
37
    {
38
        return !empty($this->driver[$name]) ? $this->driver[$name] : false;
39
    }
40
41
    /**
42
     * @inheritdoc
43
     */
44
    public function set($name, $value)
45
    {
46
        $this->driver[$name] = $value;
47
    }
48
49
    /**
50
     * 2@inheritdoc
51
     */
52
    public function delete($name)
53
    {
54
        if (!empty($this->driver[$name])) {
55
            unset($this->driver[$name]);
56
        }
57
    }
58
59
    /**
60
     * @inheritdoc
61
     */
62
    public function clean()
63
    {
64
        $this->driver = [];
65
    }
66
67
    /**
68
     * @inheritdoc
69
     */
70
    public function info()
71
    {
72
        return count($this->driver);
73
    }
74
75
    /**
76
     * @inheritdoc
77
     */
78
    public function getMeta($id)
79
    {
80
        if (!empty($this->driver[$id])) {
81
            return Type::getType($this->driver[$id]);
82
        }
83
84
        return false;
85
    }
86
87
    /**
88
     * @inheritdoc
89
     */
90
    public function increment($name, $offset = 1)
91
    {
92
        $this->driver[$name] += $offset;
93
    }
94
95
    /**
96
     * @inheritdoc
97
     */
98
    public function decrement($name, $offset = 1)
99
    {
100
        $this->driver[$name] -= $offset;
101
    }
102
}
103