SmsUpMessage   A
last analyzed

Complexity

Total Complexity 19

Size/Duplication

Total Lines 175
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 41
c 1
b 0
f 0
dl 0
loc 175
rs 10
wmc 19

13 Methods

Rating   Name   Duplication   Size   Complexity  
A sendAt() 0 5 1
A to() 0 5 1
A getLink() 0 3 1
A custom() 0 5 1
A getSendAt() 0 3 1
B formatData() 0 26 7
A getText() 0 3 1
A link() 0 5 1
A getFrom() 0 3 1
A from() 0 5 1
A getCustom() 0 3 1
A getTo() 0 3 1
A text() 0 5 1
1
<?php
2
3
namespace SquareetLabs\LaravelSmsUp;
4
5
use Carbon\Carbon;
6
7
/**
8
 * Class SmsUpMessage
9
 * @package SquareetLabs\LaravelSmsUp
10
 */
11
class SmsUpMessage
12
{
13
    /**
14
     * @var string
15
     */
16
    private $to;
17
18
    /**
19
     * @var string
20
     */
21
    private $from;
22
23
    /**
24
     * @var string
25
     */
26
    private $link;
27
28
    /**
29
     * @var string
30
     */
31
    private $text;
32
33
    /**
34
     * @var string
35
     */
36
    private $sendAt;
37
38
    /**
39
     * @var string
40
     */
41
    private $custom;
42
43
    /**
44
     * @param string $to
45
     * @return SmsUpMessage
46
     */
47
    public function to($to)
48
    {
49
        $this->to = $to;
50
51
        return $this;
52
    }
53
54
    /**
55
     * @return string|null
56
     */
57
    public function getTo()
58
    {
59
        return $this->to;
60
    }
61
62
    /**
63
     * @param string $from
64
     * @return SmsUpMessage
65
     */
66
    public function from($from)
67
    {
68
        $this->from = $from;
69
70
        return $this;
71
    }
72
73
    /**
74
     * @return string|null
75
     */
76
    public function getFrom()
77
    {
78
        return $this->from;
79
    }
80
81
    /**
82
     * @param string $link
83
     * @return SmsUpMessage
84
     */
85
    public function link($link)
86
    {
87
        $this->link = $link;
88
89
        return $this;
90
    }
91
92
    /**
93
     * @return string|null
94
     */
95
    public function getLink()
96
    {
97
        return $this->link;
98
    }
99
100
    /**
101
     * @param string $text
102
     * @return SmsUpMessage
103
     */
104
    public function text($text)
105
    {
106
        $this->text = $text;
107
108
        return $this;
109
    }
110
111
    /**
112
     * @return string|array|null
113
     */
114
    public function getText()
115
    {
116
        return $this->text;
117
    }
118
119
    /**
120
     * @param string $sendAt
121
     * @return SmsUpMessage
122
     */
123
    public function sendAt($sendAt)
124
    {
125
        $this->sendAt = $sendAt;
126
127
        return $this;
128
    }
129
130
    /**
131
     * @return string
132
     */
133
    public function getSendAt()
134
    {
135
        return $this->sendAt;
136
    }
137
138
    /**
139
     * @param string $custom
140
     * @return SmsUpMessage
141
     */
142
    public function custom($custom)
143
    {
144
        $this->custom = $custom;
145
146
        return $this;
147
    }
148
149
    /**
150
     * @return string|array|null
151
     */
152
    public function getCustom()
153
    {
154
        return $this->custom;
155
    }
156
157
    /**
158
     * @return array
159
     */
160
    public function formatData()
161
    {
162
        $payload = [];
163
164
        if (!empty($this->to)) {
165
            $payload['to'] = $this->to;
166
        }
167
        if (!empty($this->from)) {
168
            $payload['from'] = $this->from;
169
        }
170
        if (!empty($this->link)) {
171
            $payload['link'] = $this->link;
172
        }
173
        if (!empty($this->text)) {
174
            $payload['text'] = $this->text;
175
        }
176
        if (!empty($this->sendAt)) {
177
            $payload['send_at'] = $this->sendAt;
178
        } else {
179
            $payload['send_at'] = Carbon::now()->format('Y-m-d H:i:s');
180
        }
181
        if (!empty($this->custom)) {
182
            $payload['custom'] = $this->custom;
183
        }
184
185
        return $payload;
186
    }
187
}