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

StorageProvider::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 3
crap 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