Completed
Branch ci (3ae4b3)
by Дмитрий
01:37
created

AnnotationCache   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 54
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A delete() 0 3 1
A contains() 0 3 1
A getStats() 0 3 1
A fetch() 0 3 1
A save() 0 3 1
1
<?php
2
namespace yii\annotations;
3
4
use yii\caching\CacheInterface;
5
6
/**
7
 * Class AnnotationCache
8
 * @package yii\annotations
9
 */
10
class AnnotationCache implements AnnotationCacheInterface
11
{
12
    /**
13
     * @var CacheInterface
14
     */
15
    private $yiiCache;
16
17
    /**
18
     * AnnotationCache constructor.
19
     * @param CacheInterface $yiiCache
20
     */
21 8
    public function __construct(CacheInterface $yiiCache)
22
    {
23 8
        $this->yiiCache = $yiiCache;
24 8
    }
25
26
    /**
27
     * {@inheritDoc}
28
     */
29 1
    public function fetch($id)
30
    {
31 1
        return $this->yiiCache->get($id);
32
    }
33
34
    /**
35
     * {@inheritDoc}
36
     */
37 3
    public function contains($id): bool
38
    {
39 3
        return $this->yiiCache->exists($id);
40
    }
41
42
    /**
43
     * {@inheritDoc}
44
     */
45 1
    public function save($id, $data, $lifeTime = 0): bool
46
    {
47 1
        return $this->yiiCache->set($id, $data, $lifeTime);
48
    }
49
50
    /**
51
     * {@inheritDoc}
52
     */
53 1
    public function delete($id): bool
54
    {
55 1
        return $this->yiiCache->delete($id);
56
    }
57
58
    /**
59
     * {@inheritDoc}
60
     */
61 1
    public function getStats(): ?array
62
    {
63 1
        return null;
64
    }
65
}
66