Issues (3)

src/Actions/CurlRequestAction.php (1 issue)

Labels
Severity
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
It seems like $result can also be of type true; however, parameter $json of json_decode() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

38
        return json_decode(/** @scrutinizer ignore-type */ $result, true);
Loading history...
39
    }
40
}
41