Completed
Push — master ( 57883c...b5af1c )
by Jeroen
01:44
created

PrivmsgMessage   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getEventArgs() 0 4 1
1
<?php
2
3
namespace Jerodev\PhpIrcClient\Messages;
4
5
use Jerodev\PhpIrcClient\Helpers\EventArgs;
6
7
class PrivmsgMessage extends IrcMessage
8
{
9
    /** @var string */
10
    public $user;
11
12
    /** @var string */
13
    public $target;
14
15
    /** @var string */
16
    public $message;
17
18
    public function __construct(string $message)
19
    {
20
        parent::__construct($message);
21
22
        $this->user = preg_replace('/^([^!]+)!.*?$/', '$1', $this->source);
23
        $this->target = $this->commandsuffix;
24
        $this->message = $this->payload;
25
    }
26
27
    public function getEventArgs(): array
28
    {
29
        return [
30
            new EventArgs('message', [$this->user, $this->target, $this->message])
31
        ];
32
    }
33
}
34