| Conditions | 2 |
| Paths | 2 |
| Total Lines | 30 |
| Code Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 28 | private function sendRequest($data, $endpoint) |
||
| 29 | { |
||
| 30 | $method = 'POST'; |
||
| 31 | $headers = [ |
||
| 32 | 'content-type: application/json', |
||
| 33 | 'postmen-api-key: '.$this->apiKey, |
||
| 34 | ]; |
||
| 35 | $body = json_encode($data); |
||
| 36 | |||
| 37 | $curl = curl_init(); |
||
| 38 | curl_setopt_array($curl, [ |
||
| 39 | CURLOPT_RETURNTRANSFER => true, |
||
| 40 | CURLOPT_URL => $this->baseUrl.$endpoint, |
||
| 41 | CURLOPT_CUSTOMREQUEST => $method, |
||
| 42 | CURLOPT_HTTPHEADER => $headers, |
||
| 43 | CURLOPT_POSTFIELDS => $body, |
||
| 44 | CURLOPT_SSL_VERIFYPEER => false, |
||
| 45 | ]); |
||
| 46 | |||
| 47 | $response = curl_exec($curl); |
||
| 48 | $err = curl_error($curl); |
||
| 49 | |||
| 50 | curl_close($curl); |
||
| 51 | |||
| 52 | if ($err) { |
||
| 53 | echo 'cURL Error #:'.$err; |
||
| 54 | } else { |
||
| 55 | return $response; |
||
| 56 | } |
||
| 57 | } |
||
| 58 | } |
||
| 59 |
When comparing two booleans, it is generally considered safer to use the strict comparison operator.