1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace NotificationChannels\Gammu; |
4
|
|
|
|
5
|
|
|
class GammuMessage |
6
|
|
|
{ |
7
|
|
|
public $destination; |
8
|
|
|
|
9
|
|
|
public $content; |
10
|
|
|
|
11
|
|
|
public $sender; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @param string $content |
15
|
|
|
* |
16
|
|
|
* @return static |
17
|
|
|
*/ |
18
|
|
|
public static function create($content = '') |
19
|
|
|
{ |
20
|
|
|
return new static($content); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Create a new message instance. |
25
|
|
|
* |
26
|
|
|
* @param string $content |
27
|
|
|
*/ |
28
|
|
|
public function __construct($content = '') |
29
|
|
|
{ |
30
|
|
|
$this->content($content); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Destination phone number. |
35
|
|
|
* |
36
|
|
|
* @param $phoneNumber |
37
|
|
|
* |
38
|
|
|
* @return $this |
39
|
|
|
*/ |
40
|
|
|
public function to($phoneNumber) |
41
|
|
|
{ |
42
|
|
|
$this->destination = $phoneNumber; |
43
|
|
|
|
44
|
|
|
return $this; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* SMS message. |
49
|
|
|
* |
50
|
|
|
* @param $content |
51
|
|
|
* |
52
|
|
|
* @return $this |
53
|
|
|
*/ |
54
|
|
|
public function content($content) |
55
|
|
|
{ |
56
|
|
|
$this->content = $content; |
57
|
|
|
|
58
|
|
|
return $this; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Sender Phone ID. |
63
|
|
|
* |
64
|
|
|
* @param $phoneId |
65
|
|
|
* |
66
|
|
|
* @return $this |
67
|
|
|
*/ |
68
|
|
|
public function sender($phoneId = null) |
69
|
|
|
{ |
70
|
|
|
$this->sender = $phoneId; |
71
|
|
|
|
72
|
|
|
return $this; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Determine if Sender Phone ID is not given. |
77
|
|
|
* |
78
|
|
|
* @return bool |
79
|
|
|
*/ |
80
|
|
|
public function senderNotGiven() |
81
|
|
|
{ |
82
|
|
|
return empty($this->sender); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Determine if Destination Phone Number is not given. |
87
|
|
|
* |
88
|
|
|
* @return bool |
89
|
|
|
*/ |
90
|
|
|
public function destinationNotGiven() |
91
|
|
|
{ |
92
|
|
|
return empty($this->destination); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Determine if Content is not given. |
97
|
|
|
* |
98
|
|
|
* @return bool |
99
|
|
|
*/ |
100
|
|
|
public function contentNotGiven() |
101
|
|
|
{ |
102
|
|
|
return empty($this->content); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Returns params payload. |
107
|
|
|
* |
108
|
|
|
* @return array |
109
|
|
|
*/ |
110
|
|
|
public function toArray() |
111
|
|
|
{ |
112
|
|
|
return [ |
113
|
|
|
'destination' => $this->destination, |
114
|
|
|
'content' => $this->content, |
115
|
|
|
'sender' => $this->sender, |
116
|
|
|
]; |
117
|
|
|
} |
118
|
|
|
} |
119
|
|
|
|