CacheWrapper   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
c 0
b 0
f 0
lcom 1
cbo 0
dl 0
loc 43
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A has() 0 8 2
A get() 0 4 1
A set() 0 4 1
1
<?php
2
namespace Consolidation\AnnotatedCommand\Cache;
3
4
/**
5
 * Make a generic cache object conform to our expected interface.
6
 */
7
class CacheWrapper implements SimpleCacheInterface
8
{
9
    protected $dataStore;
10
11
    public function __construct($dataStore)
12
    {
13
        $this->dataStore = $dataStore;
14
    }
15
16
    /**
17
     * Test for an entry from the cache
18
     * @param string $key
19
     * @return boolean
20
     */
21
    public function has($key)
22
    {
23
        if (method_exists($this->dataStore, 'has')) {
24
            return $this->dataStore->has($key);
25
        }
26
        $test = $this->dataStore->get($key);
27
        return !empty($test);
28
    }
29
30
    /**
31
     * Get an entry from the cache
32
     * @param string $key
33
     * @return array
34
     */
35
    public function get($key)
36
    {
37
        return (array) $this->dataStore->get($key);
38
    }
39
40
    /**
41
     * Store an entry in the cache
42
     * @param string $key
43
     * @param array $data
44
     */
45
    public function set($key, $data)
46
    {
47
        $this->dataStore->set($key, $data);
48
    }
49
}
50