Conditions | 1 |
Paths | 1 |
Total Lines | 21 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
13 | public function save($data) |
||
14 | { |
||
15 | $json = json_encode($data); |
||
16 | |||
17 | $ch = curl_init($this->uri); |
||
18 | |||
19 | $headers = array( |
||
20 | 'Accept: application/json', // Prefer to receive JSON back |
||
21 | 'Content-Type: application/json' // The sent data is JSON |
||
22 | ); |
||
23 | |||
24 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); |
||
25 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
||
26 | curl_setopt($ch, CURLOPT_POSTFIELDS, $json); |
||
27 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); |
||
28 | curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); |
||
29 | |||
30 | curl_exec($ch); |
||
31 | |||
32 | curl_close($ch); |
||
33 | } |
||
34 | } |
||
35 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.