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 — master ( 50bc19...384b6d )
by Jonny
05:20
created

Client::isLazy()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
/*
4
 * This file is part of the php-phantomjs.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
namespace JonnyW\PhantomJs;
10
11
use JonnyW\PhantomJs\Procedure\ProcedureLoaderInterface;
12
use JonnyW\PhantomJs\Procedure\ProcedureCompilerInterface;
13
use JonnyW\PhantomJs\Http\MessageFactoryInterface;
14
use JonnyW\PhantomJs\Http\RequestInterface;
15
use JonnyW\PhantomJs\Http\ResponseInterface;
16
use JonnyW\PhantomJs\DependencyInjection\ServiceContainer;
17
18
/**
19
 * PHP PhantomJs
20
 *
21
 * @author Jon Wenmoth <[email protected]>
22
 */
23
class Client implements ClientInterface
24
{
25
    /**
26
     * Client.
27
     *
28
     * @var \JonnyW\PhantomJs\ClientInterface
29
     * @access private
30
     */
31
    private static $instance;
32
33
    /**
34
     * PhantomJs engine.
35
     *
36
     * @var \JonnyW\PhantomJs\Engine
37
     * @access protected
38
     */
39
    protected $engine;
40
41
    /**
42
     * Procedure loader.
43
     *
44
     * @var \JonnyW\PhantomJs\Procedure\ProcedureLoaderInterface
45
     * @access protected
46
     */
47
    protected $procedureLoader;
48
49
    /**
50
     * Procedure validator.
51
     *
52
     * @var \JonnyW\PhantomJs\Procedure\ProcedureCompilerInterface
53
     * @access protected
54
     */
55
    protected $procedureCompiler;
56
57
    /**
58
     * Message factory.
59
     *
60
     * @var \JonnyW\PhantomJs\Http\MessageFactoryInterface
61
     * @access protected
62
     */
63
    protected $messageFactory;
64
65
    /**
66
     * Procedure template
67
     *
68
     * @var string
69
     * @access protected
70
     */
71
    protected $procedure;
72
73
    /**
74
     * Internal constructor
75
     *
76
     * @access public
77
     * @param  \JonnyW\PhantomJs\Engine                               $engine
78
     * @param  \JonnyW\PhantomJs\Procedure\ProcedureLoaderInterface   $procedureLoader
79
     * @param  \JonnyW\PhantomJs\Procedure\ProcedureCompilerInterface $procedureCompiler
80
     * @param  \JonnyW\PhantomJs\Http\MessageFactoryInterface         $messageFactory
81
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
82
     */
83 35
    public function __construct(Engine $engine, ProcedureLoaderInterface $procedureLoader, ProcedureCompilerInterface $procedureCompiler, MessageFactoryInterface $messageFactory)
84
    {
85 35
        $this->engine            = $engine;
86 35
        $this->procedureLoader   = $procedureLoader;
87 35
        $this->procedureCompiler = $procedureCompiler;
88 35
        $this->messageFactory    = $messageFactory;
89 35
        $this->procedure         = 'http_default';
90 35
    }
91
92
    /**
93
     * Get singleton instance
94
     *
95
     * @access public
96
     * @return \JonnyW\PhantomJs\Client
97
     */
98 6
    public static function getInstance()
99
    {
100 6
        if (!self::$instance instanceof ClientInterface) {
101
102 1
            $serviceContainer = ServiceContainer::getInstance();
103
104 1
            self::$instance = new static(
105 1
                $serviceContainer->get('engine'),
0 ignored issues
show
Documentation introduced by
$serviceContainer->get('engine') is of type object|null, but the function expects a object<JonnyW\PhantomJs\Engine>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
106 1
                $serviceContainer->get('procedure_loader'),
0 ignored issues
show
Documentation introduced by
$serviceContainer->get('procedure_loader') is of type object|null, but the function expects a object<JonnyW\PhantomJs\...ocedureLoaderInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
107 1
                $serviceContainer->get('procedure_compiler'),
0 ignored issues
show
Documentation introduced by
$serviceContainer->get('procedure_compiler') is of type object|null, but the function expects a object<JonnyW\PhantomJs\...edureCompilerInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
108 1
                $serviceContainer->get('message_factory')
0 ignored issues
show
Documentation introduced by
$serviceContainer->get('message_factory') is of type object|null, but the function expects a object<JonnyW\PhantomJs\...essageFactoryInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
109 1
            );
110 1
        }
111
112 6
        return self::$instance;
113
    }
114
115
    /**
116
     * Get PhantomJs engine.
117
     *
118
     * @access public
119
     * @return \JonnyW\PhantomJs\Engine
120
     */
121 10
    public function getEngine()
122
    {
123 10
        return $this->engine;
124
    }
125
126
    /**
127
     * Get message factory instance
128
     *
129
     * @access public
130
     * @return \JonnyW\PhantomJs\Http\MessageFactoryInterface
131
     */
132 32
    public function getMessageFactory()
133
    {
134 32
        return $this->messageFactory;
135
    }
136
137
    /**
138
     * Get procedure loader instance
139
     *
140
     * @access public
141
     * @return \JonnyW\PhantomJs\Procedure\ProcedureLoaderInterface
142
     */
143 9
    public function getProcedureLoader()
144
    {
145 9
        return $this->procedureLoader;
146
    }
147
148
    /**
149
     * Send request
150
     *
151
     * @access public
152
     * @param  \JonnyW\PhantomJs\Http\RequestInterface  $request
153
     * @param  \JonnyW\PhantomJs\Http\ResponseInterface $response
154
     * @return \JonnyW\PhantomJs\Http\ResponseInterface
155
     */
156 31
    public function send(RequestInterface $request, ResponseInterface $response)
157
    {
158 31
        $procedure = $this->procedureLoader->load($this->procedure);
159
160 31
        $this->procedureCompiler->compile($procedure, $request);
0 ignored issues
show
Documentation introduced by
$request is of type object<JonnyW\PhantomJs\Http\RequestInterface>, but the function expects a object<JonnyW\PhantomJs\Procedure\InputInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
161
162 30
        $procedure->run($request, $response);
0 ignored issues
show
Documentation introduced by
$request is of type object<JonnyW\PhantomJs\Http\RequestInterface>, but the function expects a object<JonnyW\PhantomJs\Procedure\InputInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
$response is of type object<JonnyW\PhantomJs\Http\ResponseInterface>, but the function expects a object<JonnyW\PhantomJs\...cedure\OutputInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
163
164 30
        return $response;
165
    }
166
167
    /**
168
     * Get log.
169
     *
170
     * @access public
171
     * @return string
172
     */
173 9
    public function getLog()
174
    {
175 9
        return $this->getEngine()->getLog();
176
    }
177
178
    /**
179
     * Set procedure template.
180
     *
181
     * @access public
182
     * @param  string $procedure
183
     * @return void
184
     */
185 3
    public function setProcedure($procedure)
186
    {
187 3
        $this->procedure = $procedure;
188 3
    }
189
190
    /**
191
     * Get procedure template.
192
     *
193
     * @access public
194
     * @return string
195
     */
196
    public function getProcedure()
197
    {
198
        return $this->procedure;
199
    }
200
201
    /**
202
     * Get procedure compiler.
203
     *
204
     * @access public
205
     * @return \JonnyW\PhantomJs\Procedure\ProcedureCompilerInterface
206
     */
207
    public function getProcedureCompiler()
208
    {
209
        return $this->procedureCompiler;
210
    }
211
212
    /**
213
     * Set lazy request flag.
214
     *
215
     * @access public
216
     * @return void
217
     */
218 2
    public function isLazy()
219
    {
220 2
        $this->procedure = 'http_lazy';
221 2
    }
222
}
223