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.

ServiceAbstract::setResponse()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
crap 1
1
<?php
2
3
namespace juniorb2ss\DeathByCaptcha\Abstracts;
4
5
use Psr\Http\Message\ResponseInterface;
6
use juniorb2ss\DeathByCaptcha\DeathByCaptcha;
7
use juniorb2ss\DeathByCaptcha\Interfaces\ServiceInterface;
8
use juniorb2ss\DeathByCaptcha\Exceptions\InvalidResponseAttributeException;
9
10
abstract class ServiceAbstract implements ServiceInterface
11
{
12 51
    public function setResponse(ResponseInterface $response)
13
    {
14 51
        $bodyResponse = (string)$response->getBody();
15
16 51
        $this->objectResponse = json_decode(rtrim($bodyResponse));
0 ignored issues
show
Bug introduced by
The property objectResponse does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
17
18 51
        return $this;
19
    }
20
21 12
    public function getResponse(): \StdClass
22
    {
23 12
        return (object)$this->objectResponse;
24
    }
25
26 39
    public function getResponseAttribute(string $attribute)
27
    {
28 39
        if (isset($this->objectResponse->{$attribute})) {
29 36
            return $this->objectResponse->{$attribute};
30
        }
31
32 3
        throw new InvalidResponseAttributeException;
33
    }
34
35 6
    public function toArray(): array
36
    {
37 6
        return (array)$this->getResponse();
38
    }
39
}
40