Message::targets()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 9.4285
1
<?php
2
declare(strict_types=1);
3
4
namespace Spires\Plugins\Message\Outbound;
5
6
use Spires\Irc\Message\Outbound\RawMessage;
7
8
class Message extends RawMessage
9
{
10
    public function __construct(array $targets, string $text)
11
    {
12
        parent::__construct('PRIVMSG', implode(',', $targets) . ' :' . $text);
13
    }
14
15
    public function targets() : array
16
    {
17
        list($targets,) = explode(' ', $this->params(), 2);
18
19
        return explode(',', $targets);
20
    }
21
22
    public function text()
23
    {
24
        list(,$text) = explode(' ', $this->params(), 2);
25
26
        return ltrim($text, ':');
27
    }
28
29
    public function hasTarget($target)
30
    {
31
        return in_array($target, $this->targets());
32
    }
33
}
34