Total Complexity | 11 |
Total Lines | 98 |
Duplicated Lines | 0 % |
Coverage | 69.23% |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | class Curl implements HttpRequest |
||
11 | { |
||
12 | /** |
||
13 | * @var null|resource |
||
14 | */ |
||
15 | private $handle = null; |
||
16 | |||
17 | /** |
||
18 | * @return $this |
||
19 | */ |
||
20 | 3 | public function init() |
|
21 | { |
||
22 | 3 | if (is_null($this->handle)) { |
|
23 | 3 | $this->handle = curl_init(); |
|
|
|||
24 | 2 | } |
|
25 | |||
26 | 3 | return $this; |
|
27 | } |
||
28 | |||
29 | /** |
||
30 | * @param $url |
||
31 | * @return Curl |
||
32 | */ |
||
33 | 3 | public function setUrl($url) |
|
36 | } |
||
37 | |||
38 | /** |
||
39 | * @param $name |
||
40 | * @param $value |
||
41 | * @return Curl |
||
42 | */ |
||
43 | 3 | public function setOption($name, $value) |
|
47 | } |
||
48 | |||
49 | |||
50 | /** |
||
51 | * @return null|resource |
||
52 | */ |
||
53 | 3 | public function getHandle() |
|
54 | { |
||
55 | 3 | return $this->handle; |
|
56 | } |
||
57 | |||
58 | /** |
||
59 | * @return bool|string |
||
60 | */ |
||
61 | public function execute() |
||
62 | { |
||
63 | return curl_exec($this->handle); |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * @param $name |
||
68 | * @return mixed |
||
69 | */ |
||
70 | 3 | public function getInfo($name) |
|
73 | } |
||
74 | |||
75 | /** |
||
76 | * @return array|false |
||
77 | */ |
||
78 | public function getAllInfo() |
||
79 | { |
||
80 | return curl_getinfo($this->handle); |
||
81 | } |
||
82 | |||
83 | /** |
||
84 | * @return int |
||
85 | */ |
||
86 | public function getErrorNumber() |
||
89 | } |
||
90 | |||
91 | /** |
||
92 | * @return string |
||
93 | */ |
||
94 | public function getErrorMessage() |
||
97 | } |
||
98 | |||
99 | /** |
||
100 | * @return Curl |
||
101 | */ |
||
102 | 3 | public function close() |
|
108 | } |
||
109 | } |
||
110 |
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.