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

NameReplyMessage::handle()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 3
nc 2
nop 2
1
<?php
2
3
namespace Jerodev\PhpIrcClient\Messages;
4
5
use Jerodev\PhpIrcClient\IrcClient;
6
7
class NameReplyMessage extends IrcMessage
8
{
9
    /** @var string */
10
    public $channel;
11
12
    /** @var string[] */
13
    public $names;
14
15
    public function __construct(string $message)
16
    {
17
        parent::__construct($message);
18
19
        $this->channel = preg_replace('/^[^\#]+(\#.*?)$/', '$1', $this->commandsuffix);
20
        $this->names = preg_split('/\s+/', $this->payload, -1, PREG_SPLIT_NO_EMPTY);
0 ignored issues
show
Documentation Bug introduced by
It seems like preg_split('/\s+/', $thi...es\PREG_SPLIT_NO_EMPTY) of type false is incompatible with the declared type string[] of property $names.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
21
    }
22
    
23
    public function handle(IrcClient $client, bool $force = false): void
24
    {
25
        if ($this->handled && !$force) {
26
            return;
27
        }
28
        
29
        $client->getChannel($this->channel)->setUsers($this->names);
30
    }
31
}
32