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.
Passed
Push — master ( f9c1aa...ebbda5 )
by Steeven
19:04 queued 02:32
created

AbstractAdapter::setEngine()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 9
rs 10
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\Parser\String\Abstracts;
15
16
// ------------------------------------------------------------------------
17
18
use O2System\Spl\Traits\Collectors\ConfigCollectorTrait;
19
20
/**
21
 * Class AbstractAdapter
22
 *
23
 * @package O2System\Parser\String\Abstracts
24
 */
25
abstract class AbstractAdapter
26
{
27
    use ConfigCollectorTrait;
28
29
    /**
30
     * AbstractAdapter::$engine
31
     *
32
     * Driver Engine
33
     *
34
     * @var object
35
     */
36
    protected $engine;
37
38
    /**
39
     * AbstractAdapter::$string
40
     *
41
     * Driver Raw String
42
     *
43
     * @var string
44
     */
45
    protected $string;
46
47
    // ------------------------------------------------------------------------
48
49
    /**
50
     * AbstractAdapter::initialize
51
     *
52
     * @param array $config
53
     */
54
    abstract public function initialize(array $config = []);
55
56
    // ------------------------------------------------------------------------
57
58
    /**
59
     * AbstractAdapter::isInitialize
60
     *
61
     * @return bool
62
     */
63
    public function isInitialize()
64
    {
65
        return (bool)(empty($this->engine) ? false : true);
66
    }
67
68
    // --------------------------------------------------------------------------------------
69
70
71
    /**
72
     * AbstractAdapter::getEngine
73
     *
74
     * @return object
75
     */
76
    public function &getEngine()
77
    {
78
        return $this->engine;
79
    }
80
81
    // ------------------------------------------------------------------------
82
83
    /**
84
     * AbstractAdapter::setEngine
85
     *
86
     * @param object $engine
87
     *
88
     * @return bool
89
     */
90
    public function setEngine($engine)
91
    {
92
        if ($this->isValidEngine($engine)) {
93
            $this->engine =& $engine;
94
95
            return true;
96
        }
97
98
        return false;
99
    }
100
101
    // ------------------------------------------------------------------------
102
103
    /**
104
     * AbstractAdapter::isValidEngine
105
     *
106
     * @param object $engine
107
     *
108
     * @return mixed
109
     */
110
    abstract protected function isValidEngine($engine);
111
112
    // ------------------------------------------------------------------------
113
114
    /**
115
     * AbstractAdapter::__call
116
     *
117
     * @param string  $method
118
     * @param array   $arguments
119
     *
120
     * @return mixed|null
121
     */
122
    public function __call($method, array $arguments = [])
123
    {
124
        if (method_exists($this, $method)) {
125
            return call_user_func_array([&$this, $method], $arguments);
126
        } elseif (method_exists($this->engine, $method)) {
127
            return call_user_func_array([&$this->engine, $method], $arguments);
128
        }
129
130
        return null;
131
    }
132
133
    // ------------------------------------------------------------------------
134
135
    /**
136
     * AbstractAdapter::isSupported
137
     *
138
     * @return bool
139
     */
140
    abstract public function isSupported();
141
142
    // ------------------------------------------------------------------------
143
144
    /**
145
     * AbstractAdapter::loadFile
146
     *
147
     * @param string $filePath
148
     *
149
     * @return bool
150
     */
151
    public function loadFile($filePath)
152
    {
153
        if ($filePath instanceof \SplFileInfo) {
0 ignored issues
show
introduced by
$filePath is never a sub-type of SplFileInfo.
Loading history...
154
            $filePath = $filePath->getRealPath();
155
        }
156
157
        if (is_file($filePath)) {
158
            return $this->loadString(file_get_contents($filePath));
159
        }
160
161
        return false;
162
    }
163
164
    // ------------------------------------------------------------------------
165
166
    /**
167
     * AbstractAdapter::loadString
168
     *
169
     * @param string $string
170
     *
171
     * @return bool
172
     */
173
    public function loadString($string)
174
    {
175
        $this->string = htmlspecialchars_decode($string);
176
177
        return (bool)empty($this->string);
178
    }
179
180
    // ------------------------------------------------------------------------
181
182
    /**
183
     * AbstractAdapter::parse
184
     *
185
     * @param array $vars Variable to be parsed.
186
     *
187
     * @return string
188
     */
189
    abstract public function parse(array $vars = []);
190
}