RawMessage   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 46
rs 10
wmc 6
lcom 1
cbo 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A command() 0 4 1
A params() 0 4 1
A __toString() 0 4 1
A toArray() 0 7 1
A jsonSerialize() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Spires\Irc\Message\Outbound;
5
6
class RawMessage implements \JsonSerializable
7
{
8
    protected $command;
9
    protected $params;
10
11
    public function __construct(string $command, string $params)
12
    {
13
        $this->command = $command;
14
        $this->params = $params;
15
    }
16
17
    public function command() : string
18
    {
19
        return $this->command;
20
    }
21
22
    public function params() : string
23
    {
24
        return $this->params;
25
    }
26
27
    public function __toString() : string
28
    {
29
        return trim($this->command() . ' ' . $this->params);
30
    }
31
32
    public function toArray() : array
33
    {
34
        return [
35
            'command' => $this->command,
36
            'params' => $this->params,
37
        ];
38
    }
39
40
    /**
41
     * Specify data which should be serialized to JSON
42
     * @link http://php.net/manual/en/jsonserializable.jsonserialize.php
43
     * @return mixed data which can be serialized by <b>json_encode</b>,
44
     * which is a value of any type other than a resource.
45
     * @since 5.4.0
46
     */
47
    public function jsonSerialize()
48
    {
49
        return $this->toArray();
50
    }
51
}
52