Total Complexity | 9 |
Total Lines | 95 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
12 | class InstagramCurl |
||
13 | { |
||
14 | |||
15 | /** |
||
16 | * @var resource Curl resource instance |
||
17 | */ |
||
18 | protected $curl; |
||
19 | |||
20 | /** |
||
21 | * Make a new curl reference instance |
||
22 | */ |
||
23 | public function init() |
||
24 | { |
||
25 | $this->curl = curl_init(); |
||
|
|||
26 | } |
||
27 | |||
28 | /** |
||
29 | * Set a curl option |
||
30 | * |
||
31 | * @param $key |
||
32 | * @param $value |
||
33 | */ |
||
34 | public function setopt($key, $value) |
||
35 | { |
||
36 | curl_setopt($this->curl, $key, $value); |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * Set an array of options to a curl resource |
||
41 | * |
||
42 | * @param array $options |
||
43 | */ |
||
44 | public function setoptArray(array $options) |
||
45 | { |
||
46 | curl_setopt_array($this->curl, $options); |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * Send a curl request |
||
51 | * |
||
52 | * @return mixed |
||
53 | */ |
||
54 | public function exec() |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * Return the curl error number |
||
61 | * |
||
62 | * @return int |
||
63 | */ |
||
64 | public function errno() |
||
65 | { |
||
66 | return curl_errno($this->curl); |
||
67 | } |
||
68 | |||
69 | /** |
||
70 | * Return the curl error message |
||
71 | * |
||
72 | * @return string |
||
73 | */ |
||
74 | public function error() |
||
75 | { |
||
76 | return curl_error($this->curl); |
||
77 | } |
||
78 | |||
79 | /** |
||
80 | * Get info from a curl reference |
||
81 | * |
||
82 | * @param $type |
||
83 | * |
||
84 | * @return mixed |
||
85 | */ |
||
86 | public function getinfo($type) |
||
87 | { |
||
88 | return curl_getinfo($this->curl, $type); |
||
89 | } |
||
90 | |||
91 | /** |
||
92 | * Get the currently installed curl version |
||
93 | * |
||
94 | * @return array |
||
95 | */ |
||
96 | public function version() |
||
99 | } |
||
100 | |||
101 | /** |
||
102 | * Close the resource connection to curl |
||
103 | */ |
||
104 | public function close() |
||
107 | } |
||
108 | } |
||
109 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.