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

InviteMessage::getEvents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 0
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