ProdCacheProvider::get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BEAR\Package\Context\Provider;
6
7
use BEAR\AppMeta\AbstractAppMeta;
8
use Doctrine\Common\Cache\CacheProvider;
9
use Doctrine\Common\Cache\PhpFileCache;
10
use Ray\Di\Di\Named;
11
use Ray\Di\ProviderInterface;
12
13
class ProdCacheProvider implements ProviderInterface
14
{
15
    /** @var string */
16
    private $namespace;
17
18
    /** @var string */
19
    private $cacheDir;
20
21
    /**
22
     * @Named("namespace=cache_namespace")
23
     */
24
    public function __construct(AbstractAppMeta $appMeta, string $namespace)
25
    {
26
        $this->cacheDir = $appMeta->tmpDir . '/cache';
27
        $this->namespace = $namespace;
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function get(): CacheProvider
34
    {
35
        $cache = new PhpFileCache($this->cacheDir);
36
        $cache->setNamespace($this->namespace);
37
38
        return $cache;
39
    }
40
}
41