Completed
Push — master ( 7c39f2...831177 )
by Jeroen
04:12
created

WelcomeMessage   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 6
dl 0
loc 18
rs 10
c 0
b 0
f 0

2 Methods

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