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.

Response   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 68
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 2
A getDeviceId() 0 4 1
A getResult() 0 4 1
A getException() 0 4 1
A isSuccess() 0 4 1
1
<?php
2
3
namespace Yeelight\Bulb;
4
5
use Yeelight\Bulb\Exceptions\BulbCommandException;
6
7
class Response
8
{
9
    /**
10
     * @var int
11
     */
12
    private $deviceId;
13
14
    /**
15
     * @var array
16
     */
17
    private $result = [];
18
19
    /**
20
     * @var BulbCommandException|null
21
     */
22
    private $exception = null;
23
24
    /**
25
     * Response constructor.
26
     *
27
     * @param array $response
28
     */
29
    public function __construct(array $response)
30
    {
31
        $this->deviceId = $response['id'];
32
        if (isset($response['error'])) {
33
            $this->exception = new BulbCommandException(
34
                $response['error']['message'],
35
                $response['error']['code'],
36
                $response['id']
37
            );
38
        } else {
39
            $this->result = $response['result'];
40
        }
41
    }
42
43
    /**
44
     * @return int
45
     */
46
    public function getDeviceId(): int
47
    {
48
        return $this->deviceId;
49
    }
50
51
    /**
52
     * @return array
53
     */
54
    public function getResult(): array
55
    {
56
        return $this->result;
57
    }
58
59
    /**
60
     * @return null|BulbCommandException
61
     */
62
    public function getException()
63
    {
64
        return $this->exception;
65
    }
66
67
    /**
68
     * @return bool
69
     */
70
    public function isSuccess(): bool
71
    {
72
        return is_null($this->exception);
73
    }
74
}
75