Completed
Push — cache ( ce1318 )
by Akihito
11s
created

StorageMemcachedModule::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 9.4285
cc 1
eloc 5
nc 1
nop 2
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\Storage;
10
use Doctrine\Common\Cache\CacheProvider;
11
use Ray\Di\AbstractModule;
12
13
class StorageMemcachedModule extends AbstractModule
14
{
15
    /**
16
     * @var array
17
     */
18
    private $servers;
19
20
    public function __construct($servers, AbstractModule $module = null)
21
    {
22 1
        $this->servers = array_map(function ($serverString) {
23 1
            return explode(':', $serverString);
24 1
        }, explode(',', $servers));
25 1
        parent::__construct($module);
26 1
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31 1
    protected function configure()
32
    {
33 1
        $this->bind()->annotatedWith('memcached_servers')->toInstance($this->servers);
34 1
        $this->bind(CacheProvider::class)->annotatedWith(Storage::class)->toProvider(StorageMemcachedCacheProvider::class);
35 1
    }
36
}
37