GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — 3.0 ( c29f0e...fdb42e )
by Vermeulen
01:43
created

Memcached::obtainMemcachedClassName()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 9.6
c 0
b 0
f 0
cc 3
nc 3
nop 1
1
<?php
2
3
namespace BFW\Core\AppSystems;
4
5
use \Exception;
6
7 View Code Duplication
class Memcached extends AbstractSystem
1 ignored issue
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
8
{
9
    /**
10
     * @var \BFW\Memcache\MemcacheInterface|null $memcached The class used
11
     * to connect to memcache(d) server.
12
     * The class name should be declared into config file.
13
     */
14
    protected $memcached;
15
    
16
    /**
17
     * {@inheritdoc}
18
     */
19
    public function __invoke()
20
    {
21
        return $this->memcached;
22
    }
23
    
24
    /**
25
     * Getter accessor to property memcached
26
     * 
27
     * @return \BFW\Memcache\MemcacheInterface|null
28
     */
29
    public function getMemcached()
30
    {
31
        return $this->memcached;
32
    }
33
    
34
    /**
35
     * {@inheritdoc}
36
     * Load and initialize le memcached object
37
     */
38
    public function init()
39
    {
40
        $this->loadMemcached();
41
        $this->initStatus = true;
42
    }
43
    
44
    /**
45
     * Connect to memcache(d) server with the class declared in config file
46
     * 
47
     * @return Object
48
     * 
49
     * @throws Exception If memcached is enabled but no class is define. Or if
50
     *  The class declared into the config is not found.
51
     */
52
    protected function loadMemcached()
53
    {
54
        $memcachedConfig = \BFW\Application::getInstance()
0 ignored issues
show
Documentation Bug introduced by
The method getConfig does not exist on object<BFW\Application>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
55
            ->getConfig()
56
            ->getValue('memcached', 'memcached.php')
57
        ;
58
59
        if ($memcachedConfig['enabled'] === false) {
60
            return;
61
        }
62
63
        $this->memcached = new \BFW\Memcached;
0 ignored issues
show
Documentation Bug introduced by
It seems like new \BFW\Memcached() of type object<BFW\Memcached> is incompatible with the declared type object<BFW\Memcache\MemcacheInterface>|null of property $memcached.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
64
        $this->memcached->connectToServers();
65
    }
66
}
67