Completed
Push — 1.x ( e7c13e...e54d42 )
by Akihito
11s
created

StorageProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

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
     * @param CacheProvider $kvs
34
     * @param mixed         $appName
35
     * @param mixed         $version
36
     *
37
     * @Storage
38
     * @AppName("appName")
39
     * @CacheVersion("version")
40
     */
41 14
    public function __construct(CacheProvider $kvs, $appName, $version)
42
    {
43 14
        $this->kvs = $kvs;
44 14
        $this->appName = $appName;
45 14
        $this->version = (string) $version;
46 14
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51 14
    public function get()
52
    {
53 14
        $this->kvs->setNamespace($this->appName . $this->version);
54
55 14
        return $this->kvs;
56
    }
57
}
58