Completed
Push — spike ( a372d1...20d8a1 )
by Akihito
04:14
created

StorageProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 1 Features 1
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 39
ccs 8
cts 8
cp 1
rs 10
c 3
b 1
f 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A get() 0 6 1
1
<?php
2
/**
3
 * This file is part of the BEAR.QueryRepository package.
4
 *
5
 * @license http://opensource.org/licenses/MIT MIT
6
 */
7
namespace BEAR\QueryRepository;
8
9
use BEAR\RepositoryModule\Annotation\CacheVersion;
10
use BEAR\RepositoryModule\Annotation\Storage;
11
use BEAR\Resource\Annotation\AppName;
12
use Doctrine\Common\Cache\CacheProvider;
13
use Ray\Di\ProviderInterface;
14
15
class StorageProvider implements ProviderInterface
16
{
17
    /**
18
     * @var CacheProvider
19
     */
20
    private $kvs;
21
22
    /**
23
     * @var string
24
     */
25
    private $appName;
26
27
    /**
28
     * @var string
29
     */
30
    private $version;
31
32
    /**
33
     * @Storage
34
     * @AppName("appName")
35
     * @CacheVersion("version")
36
     */
37 15
    public function __construct(CacheProvider $kvs, string $appName, string $version)
38
    {
39 15
        $this->kvs = $kvs;
40 15
        $this->appName = $appName;
41 15
        $this->version = $version;
42 15
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47 15
    public function get()
48
    {
49 15
        $this->kvs->setNamespace($this->appName . $this->version);
50
51 15
        return $this->kvs;
52
    }
53
}
54