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.

Event   A
last analyzed

Complexity

Total Complexity 13

Size/Duplication

Total Lines 97
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 13
lcom 1
cbo 0
dl 0
loc 97
ccs 30
cts 30
cp 1
rs 10
c 0
b 0
f 0

12 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A jsonSerialize() 0 4 1
A getEvent() 0 4 1
A getChannel() 0 4 1
A getData() 0 4 1
A isError() 0 4 1
A subscriptionSucceeded() 0 4 1
A connectionEstablished() 0 4 1
A subscribeOn() 0 4 1
A unsubscribeOn() 0 4 1
A ping() 0 4 1
A createFromMessage() 0 8 2
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Client\Pusher;
4
5
final class Event implements \JsonSerializable
6
{
7
    /**
8
     * @var string
9
     */
10
    private $event;
11
12
    /**
13
     * @var string
14
     */
15
    private $channel;
16
17
    /**
18
     * @var array
19
     */
20
    private $data;
21
22
    /**
23
     * @param string $event
24
     * @param array  $data
25
     * @param string $channel
26
     */
27 15
    public function __construct(string $event, array $data, string $channel = '')
28
    {
29 15
        $this->event = $event;
30 15
        $this->data = $data;
31 15
        $this->channel = $channel;
32 15
    }
33
34 15
    public static function createFromMessage(array $message): self
35
    {
36 15
        return new self(
37 15
            $message['event'],
38 15
            \is_array($message['data']) ? $message['data'] : \json_decode($message['data'], true),
39 15
            $message['channel'] ?? ''
40
        );
41
    }
42
43 7
    public function jsonSerialize()
44
    {
45 7
        return \json_encode(['event' => $this->event, 'data' => $this->data, 'channel' => $this->channel]);
46
    }
47
48
    /**
49
     * @return string
50
     */
51 15
    public function getEvent()
52
    {
53 15
        return $this->event;
54
    }
55
56
    /**
57
     * @return string
58
     */
59 15
    public function getChannel()
60
    {
61 15
        return $this->channel;
62
    }
63
64
    /**
65
     * @return array
66
     */
67 15
    public function getData()
68
    {
69 15
        return $this->data;
70
    }
71
72 11
    public static function isError(Event $event): bool
73
    {
74 11
        return $event->getEvent() === 'pusher:error';
75
    }
76
77 8
    public static function subscriptionSucceeded(Event $event): bool
78
    {
79 8
        return $event->getEvent() !== 'pusher_internal:subscription_succeeded';
80
    }
81
82 11
    public static function connectionEstablished(Event $event): bool
83
    {
84 11
        return $event->getEvent() === 'pusher:connection_established';
85
    }
86
87 11
    public static function subscribeOn(string $channel): array
88
    {
89 11
        return ['event' => 'pusher:subscribe', 'data' => ['channel' => $channel]];
90
    }
91
92 14
    public static function unsubscribeOn(string $channel): array
93
    {
94 14
        return ['event' => 'pusher:unsubscribe', 'data' => ['channel' => $channel]];
95
    }
96
97 2
    public static function ping(): array
98
    {
99 2
        return ['event' => 'pusher:ping'];
100
    }
101
}
102