DoctrineStorage   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 49
wmc 6
lcom 1
cbo 1
ccs 15
cts 15
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A offsetExists() 0 4 1
A offsetGet() 0 6 2
A offsetSet() 0 4 1
A offsetUnset() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the Lug package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Lug\Component\Storage\Model;
13
14
use Doctrine\Common\Cache\Cache;
15
16
/**
17
 * @author GeLo <[email protected]>
18
 */
19
class DoctrineStorage implements StorageInterface
20
{
21
    /**
22
     * @var Cache
23
     */
24
    private $cache;
25
26
    /**
27
     * @param Cache $cache
28
     */
29 6
    public function __construct(Cache $cache)
30
    {
31 6
        $this->cache = $cache;
32 6
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37 1
    public function offsetExists($offset)
38
    {
39 1
        return $this->cache->contains($offset);
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45 2
    public function offsetGet($offset)
46
    {
47 2
        if (($data = $this->cache->fetch($offset)) !== false) {
48 1
            return $data;
49
        }
50 1
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55 1
    public function offsetSet($offset, $value)
56
    {
57 1
        $this->cache->save($offset, $value);
58 1
    }
59
60
    /**
61
     * {@inheritdoc}
62
     */
63 1
    public function offsetUnset($offset)
64
    {
65 1
        $this->cache->delete($offset);
66 1
    }
67
}
68