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.
Completed
Push — master ( 3758f0...0a4cf0 )
by Dirk
07:13 queued 04:47
created

Response::getMessage()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 2
eloc 2
nc 2
nop 0
crap 2
1
<?php
2
/**
3
 * Copyright 2015 Dirk Groenen
4
 *
5
 * (c) Dirk Groenen <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace DirkGroenen\Pinterest\Transport;
12
13
use DirkGroenen\Pinterest\Utils\CurlBuilder;
14
15
    /**
16
     * @property array $page
17
     * @property array $data
18
     * @property string $message
19
     */
20
class Response {
21
22
    /**
23
     * Contains the raw response
24
     *
25
     * @var string
26
     */
27
    private $response;
28
29
    /**
30
     * Used curl instance
31
     *
32
     * @var curl
33
     */
34
    private $curl;
35
36
    /**
37
     * Constructor
38
     *
39
     * @param  string        $response
40
     * @param  CurlBuilder  $curl
41
     * @param  curl    $curl
42
     */
43 33
    public function __construct($response, CurlBuilder $curl)
44
    {
45 33
        $this->response = $response;
46 33
        $this->curl = $curl;
0 ignored issues
show
Documentation Bug introduced by
It seems like $curl of type object<DirkGroenen\Pinterest\Utils\CurlBuilder> is incompatible with the declared type object<DirkGroenen\Pinterest\Transport\curl> of property $curl.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
47
48 33
        if (is_string($response)) {
49 33
            $this->response = $this->decodeString($response);
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->decodeString($response) of type array is incompatible with the declared type string of property $response.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
50 33
        }
51 33
    }
52
53
    /**
54
     * Decode the string to an array
55
     *
56
     * @access private
57
     * @param  string $response
58
     * @return array
59
     */
60 33
    private function decodeString($response)
61
    {
62 33
        return json_decode($response, true);
63
    }
64
65
    /**
66
     * Return the requested key data
67
     *
68
     * @access public
69
     * @param  string   $key
70
     * @return array
71
     */
72 27
    public function __get($key)
73
    {
74 27
        return isset($this->response[$key]) ? $this->response[$key] : [];
75
    }
76
77
    /**
78
     * Return if the key is set
79
     *
80
     * @access public
81
     * @param  string   $key
82
     * @return boolean
83
     */
84 18
    public function __isset($key)
85
    {
86 18
        return isset($this->response[$key]);
87
    }
88
89
    /**
90
     * Returns the error message which should normaly
91
     * by located in the response->message key, but can
92
     * also be localed in the response->error key.
93
     *
94
     * @return string
95
     */
96 1
    public function getMessage()
97
    {
98 1
        return (isset($this->message)) ? $this->message : $this->error;
0 ignored issues
show
Documentation introduced by
The property error does not exist on object<DirkGroenen\Pinterest\Transport\Response>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
99
    }
100
101
    /**
102
     * Get the response code from the request
103
     *
104
     * @access public
105
     * @return int
106
     */
107 33
    public function getResponseCode()
108
    {
109 33
        return $this->curl->getInfo(CURLINFO_HTTP_CODE);
110
    }
111
112
}