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 ( d88c83...a99e88 )
by Carlos
11:19
created

ServiceAbstract   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 30
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setResponse() 0 8 1
A getResponse() 0 4 1
A getResponseAttribute() 0 8 2
A toArray() 0 4 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
    public function setResponse(ResponseInterface $response)
13
    {
14
        $bodyResponse = (string)$response->getBody();
15
16
        $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
        return $this;
19
    }
20
21
    public function getResponse(): \StdClass
22
    {
23
        return (object)$this->objectResponse;
24
    }
25
26
    public function getResponseAttribute(string $attribute)
27
    {
28
        if (isset($this->objectResponse->{$attribute})) {
29
            return $this->objectResponse->{$attribute};
30
        }
31
32
        throw new InvalidResponseAttributeException;
33
    }
34
35
    public function toArray(): array
36
    {
37
        return (array)$this->getResponse();
38
    }
39
}
40