Total Complexity | 10 |
Total Lines | 62 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
9 | final class Message implements MessageInterface |
||
10 | { |
||
11 | /** |
||
12 | * @var array<string> |
||
13 | */ |
||
14 | private array $msg = []; |
||
15 | |||
16 | private int $senderId; |
||
17 | |||
18 | private ?int $recipientId; |
||
19 | |||
20 | /** |
||
21 | * @param array<string>|null $msg |
||
22 | */ |
||
23 | 36 | public function __construct( |
|
24 | ?int $senderId = null, |
||
25 | ?int $recipientId = null, |
||
26 | ?array $msg = null |
||
27 | ) { |
||
28 | 36 | $this->senderId = $senderId ?? UserEnum::USER_NOONE; |
|
29 | 36 | $this->recipientId = $recipientId; |
|
30 | 36 | if ($msg !== null) { |
|
31 | 6 | $this->msg = $msg; |
|
32 | } |
||
33 | } |
||
34 | |||
35 | 1 | public function getSenderId(): int |
|
36 | { |
||
37 | 1 | return $this->senderId; |
|
38 | } |
||
39 | |||
40 | 12 | public function getRecipientId(): ?int |
|
43 | } |
||
44 | |||
45 | 29 | public function getMessage(): array |
|
48 | } |
||
49 | |||
50 | 20 | public function add(?string $msg): void |
|
51 | { |
||
52 | 20 | if ($msg === null) { |
|
53 | 2 | return; |
|
54 | } |
||
55 | |||
56 | 18 | $this->msg[] = $msg; |
|
57 | } |
||
58 | |||
59 | 6 | public function addMessageMerge(array $msg): void |
|
66 | } |
||
67 | |||
68 | 3 | public function isEmpty(): bool |
|
73 |