GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Pull Request — master (#6)
by Sean
03:57
created

Curl::getErrorMessage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Kobas\APIClient\Request;
4
5
/**
6
 * Class Curl
7
 *
8
 * @package Kobas\APIClient\Request
9
 */
10
class Curl implements HttpRequest
11
{
12
    /**
13
     * @var null|false|resource
14
     */
15
    private $handle = null;
16
17
    /**
18
     * @return $this
19
     */
20 3
    public function init()
21
    {
22 3
        if (is_null($this->handle)) {
23 3
            $this->handle = curl_init();
24 2
        }
25
26 3
        return $this;
27
    }
28
29
    /**
30
     * @param $url
31
     * @return Curl
32
     */
33 3
    public function setUrl($url)
34
    {
35 3
        return $this->setOption(CURLOPT_URL, $url);
36
    }
37
38
    /**
39
     * @param $name
40
     * @param $value
41
     * @return Curl
42
     */
43 3
    public function setOption($name, $value)
44
    {
45 3
        curl_setopt($this->handle, $name, $value);
0 ignored issues
show
Bug introduced by
It seems like $this->handle can also be of type boolean; 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

45
        curl_setopt(/** @scrutinizer ignore-type */ $this->handle, $name, $value);
Loading history...
46 3
        return $this;
47
    }
48
49
50
    /**
51
     * @return false| resource
52
     */
53 3
    public function getHandle()
54
    {
55 3
        return $this->handle;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->handle also could return the type boolean which is incompatible with the documented return type false|resource.
Loading history...
56
    }
57
58
    /**
59
     * @return bool|string
60
     */
61
    public function execute()
62
    {
63
        return curl_exec($this->handle);
0 ignored issues
show
Bug introduced by
It seems like $this->handle can also be of type boolean; 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

63
        return curl_exec(/** @scrutinizer ignore-type */ $this->handle);
Loading history...
64
    }
65
66
    /**
67
     * @param $name
68
     * @return mixed
69
     */
70 3
    public function getInfo($name)
71
    {
72 3
        return curl_getinfo($this->handle, $name);
0 ignored issues
show
Bug introduced by
It seems like $this->handle can also be of type boolean; however, parameter $ch of curl_getinfo() 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

72
        return curl_getinfo(/** @scrutinizer ignore-type */ $this->handle, $name);
Loading history...
73
    }
74
75
    /**
76
     * @return array|false
77
     */
78
    public function getAllInfo()
79
    {
80
        return curl_getinfo($this->handle);
0 ignored issues
show
Bug introduced by
It seems like $this->handle can also be of type boolean; however, parameter $ch of curl_getinfo() 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

80
        return curl_getinfo(/** @scrutinizer ignore-type */ $this->handle);
Loading history...
81
    }
82
83
    /**
84
     * @return int|mixed
85
     */
86
    public function getErrorNumber()
87
    {
88
        return curl_errno($this->handle);
0 ignored issues
show
Bug introduced by
It seems like $this->handle can also be of type boolean; however, parameter $ch of curl_errno() 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

88
        return curl_errno(/** @scrutinizer ignore-type */ $this->handle);
Loading history...
89
    }
90
91
    /**
92
     * @return mixed|string
93
     */
94
    public function getErrorMessage()
95
    {
96
        return curl_error($this->handle);
0 ignored issues
show
Bug introduced by
It seems like $this->handle can also be of type boolean; however, parameter $ch of curl_error() 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

96
        return curl_error(/** @scrutinizer ignore-type */ $this->handle);
Loading history...
97
    }
98
99
    /**
100
     * @return Curl
101
     */
102 3
    public function close()
103
    {
104 3
        curl_close($this->handle);
0 ignored issues
show
Bug introduced by
It seems like $this->handle can also be of type boolean; 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

104
        curl_close(/** @scrutinizer ignore-type */ $this->handle);
Loading history...
105 3
        $this->handle = null;
106
107 3
        return $this;
108
    }
109
}
110