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

ApcuCacheFactory   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A create() 0 8 3
1
<?php
2
3
namespace SilverStripe\Core\Cache;
4
5
use SilverStripe\Core\Injector\Injector;
6
use Symfony\Component\Cache\Simple\ApcuCache;
7
use Memcached;
8
9
class ApcuCacheFactory implements CacheFactory
10
{
11
12
    /**
13
     * @var string
14
     */
15
    protected $version;
16
17
    /**
18
     * @param string $version
19
     */
20
    public function __construct($version = null)
21
    {
22
        $this->version = $version;
23
    }
24
25
    /**
26
     * @inheritdoc
27
     */
28
    public function create($service, array $params = array())
29
    {
30
        return Injector::inst()->create(ApcuCache::class, false, [
31
            (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...
32
            (isset($args['defaultLifetime'])) ? $args['defaultLifetime'] : 0,
33
            $this->version
34
        ]);
35
    }
36
}
37