Passed
Push — master ( b1e531...74002f )
by Jeroen
01:49
created

PingMessage::getEvents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Jerodev\PhpIrcClient\Messages;
4
5
use Jerodev\PhpIrcClient\Helpers\Event;
6
use Jerodev\PhpIrcClient\IrcClient;
7
8
class PingMessage extends IrcMessage
9
{
10
    public function __construct(string $message)
11
    {
12
        parent::__construct($message);
13
    }
14
15
    /**
16
     *  Reply the ping message with a pong response.
17
     */
18
    public function handle(IrcClient $client, bool $force = false): void
19
    {
20
        if ($this->handled && !$force) {
21
            return;
22
        }
23
24
        $client->send("PONG :$this->payload");
25
    }
26
27
    public function getEvents(): array
28
    {
29
        return [
30
            new Event('ping')
31
        ];
32
    }
33
}
34