sfneal /
google-places
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Sfneal\GooglePlaces\Actions; |
||
| 4 | |||
| 5 | use Sfneal\Actions\Action; |
||
| 6 | |||
| 7 | class CurlRequestAction extends Action |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * @var string |
||
| 11 | */ |
||
| 12 | private $endpoint; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * CurlRequestAction constructor. |
||
| 16 | * |
||
| 17 | * @param string $endpoint |
||
| 18 | */ |
||
| 19 | public function __construct(string $endpoint) |
||
| 20 | { |
||
| 21 | $this->endpoint = $endpoint; |
||
| 22 | } |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Execute the cURL request and JSON decode the result. |
||
| 26 | * |
||
| 27 | * @return mixed |
||
| 28 | */ |
||
| 29 | public function execute() |
||
| 30 | { |
||
| 31 | $ch = curl_init(); |
||
| 32 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); |
||
| 33 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
||
| 34 | curl_setopt($ch, CURLOPT_URL, $this->endpoint); |
||
| 35 | $result = curl_exec($ch); |
||
| 36 | curl_close($ch); |
||
| 37 | |||
| 38 | return json_decode($result, true); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 39 | } |
||
| 40 | } |
||
| 41 |