Passed
Push — main ( f6b00c...c5d93b )
by Alejandro
08:00 queued 05:26
created

WhatsAppTextMessage::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php
2
3
namespace NotificationChannels\WhatsApp;
4
5
class WhatsAppTextMessage
6
{
7
    /**
8
     * WhatsApp ID or phone number for the person you want to send a message to.
9
     */
10
    protected string $to;
11
12
    /**
13
     * Message.
14
     */
15
    protected string $message;
16
17
    /**
18
     * The message type.
19
     */
20
    protected static string $type = 'text';
21
22 4
    protected function __construct($to = '', $message = '')
23
    {
24 4
        $this->to = $to;
25 4
        $this->message = $message;
26
    }
27
28 4
    public static function create($to = '', $message = ''): self
29
    {
30 4
        return new self($to, $message);
31
    }
32
33 2
    public function to(string $to): self
34
    {
35 2
        $this->to = $to;
36
37 2
        return $this;
38
    }
39
40 1
    public function message(string $message): self
41
    {
42 1
        $this->message = $message;
43
44 1
        return $this;
45
    }
46
47 1
    public function getMessage(): string
48
    {
49 1
        return $this->message;
50
    }
51
52 1
    public function recipient(): ?string
53
    {
54 1
        return $this->to;
55
    }
56
57 1
    public function hasRecipient(): bool
58
    {
59 1
        return ! empty($this->to);
60
    }
61
62 1
    public function type(): string
63
    {
64 1
        return self::$type;
65
    }
66
}
67