Completed
Pull Request — master (#6648)
by Ingo
08:49
created

MemcachedCacheFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SilverStripe\Core\Cache;
4
5
use SilverStripe\Core\Injector\Injector;
6
use Symfony\Component\Cache\Simple\MemcachedCache;
7
use Memcached;
8
9
class MemcachedCacheFactory implements CacheFactory
10
{
11
12
    /**
13
     * @var Memcached
14
     */
15
    protected $memcachedClient;
16
17
    /**
18
     * @param Memcached $memcachedClient
19
     */
20
    public function __construct(Memcached $memcachedClient)
21
    {
22
        $this->memcachedClient = $memcachedClient;
23
    }
24
25
    /**
26
     * @inheritdoc
27
     */
28
    public function create($service, array $params = array())
29
    {
30
        return Injector::inst()->create(MemcachedCache::class, false, [
31
            $this->memcachedClient,
32
            (isset($args['namespace'])) ? $args['namespace'] : '',
0 ignored issues
show
Bug introduced by
The variable $args seems to never exist, and therefore isset should always return false. Did you maybe rename this variable?

This check looks for calls to isset(...) or empty() on variables that are yet undefined. These calls will always produce the same result and can be removed.

This is most likely caused by the renaming of a variable or the removal of a function/method parameter.

Loading history...
33
            (isset($args['defaultLifetime'])) ? $args['defaultLifetime'] : 0
34
        ]);
35
    }
36
}
37