ProdCacheProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 28
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A get() 0 7 1
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