DoctrineCache::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
namespace SkautisBundle\Skautis\Wsdl\Decorator\Cache;
4
5
use Skautis\Wsdl\Decorator\Cache\CacheInterface;
6
use Doctrine\Common\Cache\Cache;
7
8
/**
9
 * Trida implementujici Skautis cache interface pomoci DoctrineCache
10
 */
11
class DoctrineCache implements CacheInterface
12
{
13
14
    /**
15
     * @var Cache
16
     */
17
    protected $doctrineCache;
18
19
    /**
20
     * @var int
21
     */
22
    protected $ttl;
23
24
    public function __construct(Cache $doctrineCache, $ttl = 0)
25
    {
26
        $this->doctrineCache = $doctrineCache;
27
        $this->ttl = $ttl;
28
    }
29
30
    /**
31
     * @inheritdoc
32
     */
33
    public function get($key)
34
    {
35
        $data = $this->doctrineCache->fetch($key);
36
37
        if ($data === false) {
38
            return null;
39
        }
40
41
        return $data;
42
    }
43
44
    /**
45
     * @inheritdoc
46
     */
47
    public function set($key, $value)
48
    {
49
        $this->doctrineCache->save($key, $value, $this->ttl);
50
    }
51
}
52