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.

Curl   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 105
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 105
rs 10
c 0
b 0
f 0
wmc 7
lcom 1
cbo 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 8 1
A options() 0 8 1
A post() 0 7 1
A option() 0 4 1
A exec() 0 4 1
A close() 0 6 1
A response() 0 4 1
1
<?php
2
namespace zServices\Miscellany;
3
4
/**
5
*
6
*/
7
class Curl
8
{
9
10
	/**
11
	 * URL to Request
12
	 * @var string
13
	 */
14
	private $url;
15
16
	/**
17
	 * Options to request
18
	 * @var array
19
	 */
20
	private $options = [];
21
22
	/**
23
	 * Object instance
24
	 * @var object
25
	 */
26
	private $instance;
27
28
	/**
29
	 * Response from request
30
	 * @var string
31
	 */
32
	private $response;
33
34
	/**
35
	 * Initialize
36
	 * @param string $url
37
	 * @return Curl
38
	 */
39
	public function init($url)
40
	{
41
		$this->instance = curl_init($url);
0 ignored issues
show
Documentation Bug introduced by
It seems like curl_init($url) of type resource is incompatible with the declared type object of property $instance.

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...
42
43
		$this->url = $url;
44
45
		return $this;
46
	}
47
48
	/**
49
	 * Set option
50
	 * @param  array  $options
51
	 * @return Curl
52
	 */
53
	public function options(array $options)
54
	{
55
		$this->options = $options;
56
57
		curl_setopt_array($this->instance, $this->options);
58
59
		return $this;
60
	}
61
62
	/**
63
	 * POST Params
64
	 * @return Curl
65
	 */
66
	public function post(array $fields)
67
	{
68
		$this->option(CURLOPT_POST, count($fields));
0 ignored issues
show
Documentation introduced by
count($fields) is of type integer, but the function expects a object<zServices\Miscellany\mix>.

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...
69
		$this->option(CURLOPT_POSTFIELDS, http_build_query($fields));
0 ignored issues
show
Documentation introduced by
http_build_query($fields) is of type string, but the function expects a object<zServices\Miscellany\mix>.

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...
70
71
		return $this;
72
	}
73
74
	/**
75
	 * Set option in cURL
76
	 * @param  integer $option 
77
	 * @param  mix $value 
78
	 */
79
	public function option($option, $value)
80
	{
81
		curl_setopt($this->instance, $option, $value);
82
	}
83
84
	/**
85
	 * Request
86
	 */
87
	public function exec()
88
	{
89
		$this->response = curl_exec($this->instance);
90
	}
91
92
	/**
93
	 * Close connection
94
	 * @return Curl
95
	 */
96
	public function close()
97
	{
98
		curl_close($this->instance);
99
100
		return $this;
101
	}
102
103
	/**
104
	 * Return response from request
105
	 * @return string
106
	 */
107
	public function response()
108
	{
109
		return $this->response;
110
	}
111
}