Conditions | 2 |
Paths | 2 |
Total Lines | 27 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
62 | protected function doRequest(string $method, string $path, string $data): array |
||
63 | { |
||
64 | $conn = curl_init(); |
||
65 | |||
66 | curl_setopt_array( |
||
67 | $conn, |
||
68 | [ |
||
69 | CURLOPT_URL => $path, |
||
70 | CURLOPT_TIMEOUT => 15, |
||
71 | CURLOPT_RETURNTRANSFER => 1, |
||
72 | CURLOPT_CUSTOMREQUEST => $method, |
||
73 | CURLOPT_FORBID_REUSE => 1, |
||
74 | CURLOPT_POSTFIELDS => $data, |
||
75 | ] |
||
76 | ); |
||
77 | |||
78 | $response = curl_exec($conn); |
||
79 | $data = null; |
||
80 | |||
81 | if (false !== $response) { |
||
82 | $data = json_decode($response, true); |
||
83 | } |
||
84 | |||
85 | curl_close($conn); |
||
86 | |||
87 | return $data ?? []; |
||
88 | } |
||
89 | } |
||
90 |