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.

AbstractAdapter::__construct()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 10
nc 4
nop 1
dl 0
loc 15
rs 9.9332
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of the O2System Framework package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @author         Steeve Andrian Salim
9
 * @copyright      Copyright (c) Steeve Andrian Salim
10
 */
11
12
// ------------------------------------------------------------------------
13
14
namespace O2System\Cache\Abstracts;
15
16
// ------------------------------------------------------------------------
17
18
use O2System\Cache\DataStructures\Config;
19
use O2System\Spl\Exceptions\Logic\BadFunctionCall\BadDependencyCallException;
20
21
/**
22
 * Class AbstractAdapter
23
 *
24
 * @package O2System\Cache\Abstracts
25
 */
26
abstract class AbstractAdapter extends AbstractItemPool
27
{
28
    /**
29
     * AbstractAdapter::$platform
30
     *
31
     * Adapter Platform Name
32
     *
33
     * @var string
34
     */
35
    protected $platform;
36
37
    /**
38
     * Adapter Config
39
     *
40
     * @var array
41
     */
42
    protected $config = [];
43
44
    /**
45
     * AbstractAdapter::$config
46
     *
47
     * Adapter Prefix Key
48
     *
49
     * @var string
50
     */
51
    protected $prefixKey;
52
53
    // ------------------------------------------------------------------------
54
55
    /**
56
     * AbstractAdapter::__construct
57
     *
58
     * @param \O2System\Cache\DataStructures\Config|NULL $config
59
     *
60
     * @return AbstractAdapter
61
     * @throws BadDependencyCallException
62
     */
63
    public function __construct(Config $config = null)
64
    {
65
        language()
66
            ->addFilePath(str_replace('Abstracts', '', __DIR__) . DIRECTORY_SEPARATOR)
67
            ->loadFile('cache');
68
69
        if (isset($config)) {
70
            if ($this->isSupported()) {
71
                $this->connect($config->getArrayCopy());
72
73
                if ($config->offsetExists('prefixKey')) {
74
                    $this->setPrefixKey($config->prefixKey);
0 ignored issues
show
Bug Best Practice introduced by
The property prefixKey does not exist on O2System\Cache\DataStructures\Config. Since you implemented __get, consider adding a @property annotation.
Loading history...
75
                }
76
            } else {
77
                throw new BadDependencyCallException('E_UNSUPPORTED_ADAPTER_CACHE_EXCEPTION', 0, [$this->platform]);
78
            }
79
        }
80
    }
81
82
    // ------------------------------------------------------------------------
83
84
    /**
85
     * AbstractAdapter::isSupported
86
     *
87
     * Checks if this adapter is supported on this system.
88
     *
89
     * @return bool Returns FALSE if not supported.
90
     */
91
    abstract public function isSupported();
92
93
    // ------------------------------------------------------------------------
94
95
    /**
96
     * AbstractAdapter::setPrefixKey
97
     *
98
     * Sets item prefix key.
99
     *
100
     * @param $prefixKey
101
     */
102
    public function setPrefixKey($prefixKey)
103
    {
104
        $this->prefixKey = rtrim($prefixKey, ':') . ':';
105
    }
106
107
    // ------------------------------------------------------------------------
108
109
    /**
110
     * AbstractAdapter::getPlatform
111
     *
112
     * Gets item pool adapter platform name.
113
     *
114
     * @return string
115
     */
116
    public function getPlatform()
117
    {
118
        return $this->platform;
119
    }
120
121
    // ------------------------------------------------------------------------
122
123
    /**
124
     * AbstractAdapter::isConnected
125
     *
126
     * Checks if this adapter has a successful connection.
127
     *
128
     * @return bool Returns FALSE if not supported.
129
     */
130
    abstract public function isConnected();
131
}