Completed
Pull Request — master (#2)
by Simon
03:13
created

SipgateMessage::recipient()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace NotificationChannels\Sipgate;
4
5
use Illuminate\Contracts\Support\Arrayable;
6
use JsonSerializable;
7
8
class SipgateMessage implements Arrayable, JsonSerializable
9
{
10
    /** @var string */
11
    protected $message;
12
13
    /** @var string */
14
    protected $recipient;
15
16
    /** @var string */
17
    protected $smsId;
18
19
    /** @var int */
20
    protected $sendAt;
21
22
    /**
23
     * SipgateMessage constructor.
24
     * @param  string  $message
25
     */
26 19
    public function __construct(string $message = '')
27
    {
28 19
        $this->message = $message;
29 19
    }
30
31
    /**
32
     * @param  string  $message
33
     * @return static
34
     */
35 8
    public static function create(string $message = '')
36
    {
37 8
        return new static($message);
38
    }
39
40
    /**
41
     * @return string
42
     */
43 7
    public function getSmsId()
44
    {
45 7
        return $this->smsId;
46
    }
47
48
    /**
49
     * @param  string  $smsId
50
     *
51
     * @return SipgateMessage
52
     */
53 10
    public function smsId(string $smsId)
54
    {
55 10
        $this->smsId = $smsId;
56
57 10
        return $this;
58
    }
59
60
    /**
61
     * @return string
62
     */
63 3
    public function getMessage()
64
    {
65 3
        return $this->message;
66
    }
67
68
    /**
69
     * @param  string  $message
70
     * @return SipgateMessage
71
     */
72 4
    public function message(string $message)
73
    {
74 4
        $this->message = $message;
75
76 4
        return $this;
77
    }
78
79
    /**
80
     * @return string
81
     */
82 8
    public function getRecipient()
83
    {
84 8
        return $this->recipient;
85
    }
86
87
    /**
88
     * @param  string  $recipient
89
     * @return SipgateMessage
90
     */
91 10
    public function recipient(string $recipient)
92
    {
93 10
        $this->recipient = $recipient;
94
95 10
        return $this;
96
    }
97
98
    /**
99
     * @return int | null
100
     */
101 1
    public function getSendAt()
102
    {
103 1
        return $this->sendAt;
104
    }
105
106
    /**
107
     * @param  int  $sendAt
108
     * @return SipgateMessage
109
     */
110 4
    public function sendAt($sendAt)
111
    {
112 4
        $this->sendAt = $sendAt;
113
114 4
        return $this;
115
    }
116
117
    /**
118
     * @return array
119
     */
120 1
    public function toArray()
121
    {
122
        return [
123 1
            'message' => $this->message,
124 1
            'recipient' => $this->recipient,
125 1
            'smsId' => $this->smsId,
126 1
            'sendAt' => $this->sendAt,
127
        ];
128
    }
129
130
    /**
131
     * @return array
132
     */
133
    public function jsonSerialize()
134
    {
135
        return $this->toArray();
136
    }
137
}
138