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

WelcomeMessage   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A handle() 0 8 4
A getEvents() 0 4 1
1
<?php
2
3
namespace Jerodev\PhpIrcClient\Messages;
4
5
use Jerodev\PhpIrcClient\Helpers\Event;
6
use Jerodev\PhpIrcClient\IrcClient;
7
8
class WelcomeMessage extends IrcMessage
9
{
10
    public function __construct(string $message)
11
    {
12
        parent::__construct($message);
13
    }
14
15
    /**
16
     *  On welcome message, join the selected channels.
17
     */
18
    public function handle(IrcClient $client, bool $force = false): void
19
    {
20
        if ($this->handled && !$force) {
21
            return;
22
        }
23
24
        foreach ($client->getChannels() as $channel) {
25
            $client->join($channel->getName());
26
        }
27
    }
28
29
    public function getEvents(): array
30
    {
31
        return [
32
            new Event('registered')
33
        ];
34
    }
35
}
36