Passed
Pull Request — master (#12)
by
unknown
08:46
created

InviteMessage   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 10
c 1
b 0
f 0
dl 0
loc 24
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A getEvents() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Jerodev\PhpIrcClient\Messages;
6
7
use Jerodev\PhpIrcClient\Helpers\Event;
8
use Jerodev\PhpIrcClient\IrcChannel;
9
use Jerodev\PhpIrcClient\IrcClient;
10
11
class InviteMessage extends IrcMessage
12
{
13
    /**
14
     * Name of the user inviting the client to.
15
     */
16
    public string $user;
17
18
    public function __construct(string $command)
19
    {
20
        parent::__construct($command);
21
        [$this->user] = explode(' ', $command);
22
        [$this->user] = explode('!', $this->user);
23
        $this->user = substr($this->user, 1);
24
        $this->target = $this->payload;
25
        $this->channel = new IrcChannel($this->target);
26
    }
27
28
    /**
29
     * @return array<int, Event>
30
     */
31
    public function getEvents(): array
32
    {
33
        return [
34
            new Event('invite', [$this->channel, $this->user]),
35
        ];
36
    }
37
}
38