Completed
Push — cache-namespace ( 3a7175...f0ed7e )
by Akihito
02:41
created

NamespacedCacheProvider::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BEAR\QueryRepository;
6
7
use BEAR\RepositoryModule\Annotation\CacheEngine;
8
use BEAR\RepositoryModule\Annotation\CacheVersion;
9
use BEAR\Resource\Annotation\AppName;
10
use Doctrine\Common\Cache\CacheProvider;
11
use Ray\Di\ProviderInterface;
12
13
class NamespacedCacheProvider implements ProviderInterface
14
{
15
    /**
16
     * @var CacheProvider
17
     */
18
    private $cache;
19
20
    /**
21
     * @CacheEngine("cache")
22
     * @AppName("appName")
23
     * @CacheVersion("version")
24
     */
25
    public function __construct(CacheProvider $cache, string $appName = '', string $version = '')
26
    {
27
        $cache->setNamespace($appName . ':' . $version);
28
        $this->cache = $cache;
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function get()
35
    {
36
        return $this->cache;
37
    }
38
}
39