Passed
Push — master ( 25ef95...88bd2b )
by Stephen
02:06
created

CurlRequestAction::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
nc 1
nop 1
dl 0
loc 8
rs 10
c 1
b 0
f 0
1
<?php
2
3
4
namespace Sfneal\GooglePlaces\Actions;
5
6
7
use Sfneal\Actions\AbstractActionStatic;
8
9
class CurlRequestAction extends AbstractActionStatic
10
{
11
    /**
12
     * Execute the cURL request and JSON decode the result
13
     *
14
     * @param string $endpoint
15
     * @return mixed
16
     */
17
    public static function execute(string $endpoint) {
18
        $ch = curl_init();
19
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
0 ignored issues
show
Bug introduced by
It seems like $ch can also be of type false; however, parameter $ch of curl_setopt() does only seem to accept resource, 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

19
        curl_setopt(/** @scrutinizer ignore-type */ $ch, CURLOPT_SSL_VERIFYPEER, false);
Loading history...
20
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
21
        curl_setopt($ch, CURLOPT_URL, $endpoint);
22
        $result = curl_exec($ch);
0 ignored issues
show
Bug introduced by
It seems like $ch can also be of type false; however, parameter $ch of curl_exec() does only seem to accept resource, 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

22
        $result = curl_exec(/** @scrutinizer ignore-type */ $ch);
Loading history...
23
        curl_close($ch);
0 ignored issues
show
Bug introduced by
It seems like $ch can also be of type false; however, parameter $ch of curl_close() does only seem to accept resource, 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

23
        curl_close(/** @scrutinizer ignore-type */ $ch);
Loading history...
24
        return json_decode($result, true);
25
    }
26
}
27