| Conditions | 6 |
| Paths | 12 |
| Total Lines | 29 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 52 | protected function callApi($method, $url, $params = null, $headers = []) |
||
| 53 | { |
||
| 54 | $options = [ |
||
| 55 | 'query' => [ |
||
| 56 | 'usercode' => $this->credentials['user_code'], |
||
| 57 | 'password' => $this->credentials['secret'], |
||
| 58 | ], |
||
| 59 | ]; |
||
| 60 | |||
| 61 | if ($method == 'POST') { |
||
| 62 | if (is_array($params)) { |
||
| 63 | $options['form_params'] = $params; |
||
| 64 | } else { |
||
| 65 | $options['body'] = $params; |
||
| 66 | } |
||
| 67 | } |
||
| 68 | |||
| 69 | if ($method == 'GET' && is_array($params)) { |
||
| 70 | $options['query'] = array_merge($options['query'], $params); |
||
| 71 | } |
||
| 72 | |||
| 73 | if ($headers) { |
||
|
|
|||
| 74 | $options['headers'] = $headers; |
||
| 75 | } |
||
| 76 | |||
| 77 | $response = $this->client->request($method, $url, $options); |
||
| 78 | |||
| 79 | return $response->getBody()->getContents(); |
||
| 80 | } |
||
| 81 | } |
||
| 82 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.