NameReplyMessage::handle()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 4
nc 3
nop 2
dl 0
loc 8
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 NameReplyMessage extends IrcMessage
9
{
10
    /** @var string */
11
    public $channel;
12
13
    /** @var string[] */
14
    public $names;
15
16
    public function __construct(string $message)
17
    {
18
        parent::__construct($message);
19
20
        $this->channel = strstr($this->commandsuffix, '#');
21
        $this->names = explode(' ', $this->payload);
22
    }
23
24
    public function handle(IrcClient $client, bool $force = false): void
25
    {
26
        if ($this->handled && !$force) {
27
            return;
28
        }
29
30
        if (!empty($this->names)) {
31
            $client->getChannel($this->channel)->setUsers($this->names);
32
        }
33
    }
34
35
    public function getEvents(): array
36
    {
37
        return [
38
            new Event('names', [$this->channel, $this->names]),
39
            new Event("names$this->channel", [$this->names]),
40
        ];
41
    }
42
}
43