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 ( 5276e1...94e02b )
by Vermeulen
01:25
created

Memcached::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace BFW\Core\AppSystems;
4
5
use \Exception;
6
7
class Memcached extends AbstractSystem
8
{
9
    /**
10
     * @var \BFW\Memcached $memcached The class used to connect to
11
     * memcache(d) server.
12
     * The class name should be declared into config file.
13
     */
14
    protected $memcached;
15
    
16
    /**
17
     * Load and initialize le memcached object
18
     */
19
    public function __construct()
20
    {
21
        $this->loadMemcached();
22
    }
23
    
24
    /**
25
     * {@inheritdoc}
26
     * 
27
     * @return \BFW\Memcached
28
     */
29
    public function __invoke()
30
    {
31
        return $this->memcached;
32
    }
33
    
34
    /**
35
     * Getter accessor to property memcached
36
     * 
37
     * @return \BFW\Memcached
38
     */
39
    public function getMemcached()
40
    {
41
        return $this->memcached;
42
    }
43
    
44
    /**
45
     * Connect to memcache(d) server with the class declared in config file
46
     * 
47
     * @return void
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()
55
            ->getConfig()
56
            ->getValue('memcached', 'memcached.php')
57
        ;
58
59
        if ($memcachedConfig['enabled'] === false) {
60
            return;
61
        }
62
63
        try {
64
            $this->memcached = new \BFW\Memcached;
65
            $this->memcached->connectToServers();
66
        } catch (Exception $e) {
67
            $this->memcached = null;
68
            
69
            trigger_error(
70
                'Memcached connexion error'
71
                .' #'.$e->getCode().' : '.$e->getMessage(),
72
                E_USER_WARNING
73
            );
74
        }
75
    }
76
}
77