CurlRequestAction   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 32
rs 10
c 2
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A execute() 0 10 1
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
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