@@ -39,10 +39,10 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function __construct() |
41 | 41 | { |
42 | - $this->username = config('sms.drivers.' . $this->drive . '.username'); |
|
43 | - $this->password = config('sms.drivers.' . $this->drive . '.password'); |
|
44 | - $this->from = config('sms.drivers.' . $this->drive . '.from'); |
|
45 | - $this->url = config('sms.drivers.' . $this->drive . '.urlPattern'); |
|
42 | + $this->username = config('sms.drivers.'.$this->drive.'.username'); |
|
43 | + $this->password = config('sms.drivers.'.$this->drive.'.password'); |
|
44 | + $this->from = config('sms.drivers.'.$this->drive.'.from'); |
|
45 | + $this->url = config('sms.drivers.'.$this->drive.'.urlPattern'); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -208,8 +208,7 @@ discard block |
||
208 | 208 | { |
209 | 209 | $inputs = $this->setMessageExceptions(); |
210 | 210 | |
211 | - $param = array |
|
212 | - ( |
|
211 | + $param = array( |
|
213 | 212 | 'lineNumber' => $this->from, |
214 | 213 | 'MessageText' => $text, |
215 | 214 | 'Mobiles' => json_encode($inputs['numbers']), |
@@ -230,11 +229,11 @@ discard block |
||
230 | 229 | |
231 | 230 | private function setMessageExceptions() |
232 | 231 | { |
233 | - $apiKey = config('sms.drivers.' . $this->drive . '.apiKey'); |
|
232 | + $apiKey = config('sms.drivers.'.$this->drive.'.apiKey'); |
|
234 | 233 | if ($apiKey == '') |
235 | 234 | throw new \Exception('The apiKey of SMS.ir muse be set in config'); |
236 | 235 | |
237 | - $this->url = config('sms.drivers.' . $this->drive . '.urlNormal'); |
|
236 | + $this->url = config('sms.drivers.'.$this->drive.'.urlNormal'); |
|
238 | 237 | if ($this->url == '') |
239 | 238 | throw new \Exception('The url of SMS.ir muse be set in config'); |
240 | 239 |
@@ -50,10 +50,11 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public function send() |
52 | 52 | { |
53 | - if ($this->method == 'pattern') |
|
54 | - $res = $this->sendPattern(); |
|
55 | - else |
|
56 | - $res = $this->message($this->text); |
|
53 | + if ($this->method == 'pattern') { |
|
54 | + $res = $this->sendPattern(); |
|
55 | + } else { |
|
56 | + $res = $this->message($this->text); |
|
57 | + } |
|
57 | 58 | return $res; |
58 | 59 | } |
59 | 60 | |
@@ -75,8 +76,9 @@ discard block |
||
75 | 76 | public function pattern($pattern_code = null) |
76 | 77 | { |
77 | 78 | $this->method = 'pattern'; |
78 | - if ($pattern_code) |
|
79 | - $this->pattern_code = $pattern_code; |
|
79 | + if ($pattern_code) { |
|
80 | + $this->pattern_code = $pattern_code; |
|
81 | + } |
|
80 | 82 | return $this; |
81 | 83 | } |
82 | 84 | |
@@ -156,31 +158,38 @@ discard block |
||
156 | 158 | private function setPatternExceptions() |
157 | 159 | { |
158 | 160 | $parameters = $this->data; |
159 | - if (is_null($parameters)) |
|
160 | - throw new \Exception('The data must be set'); |
|
161 | - elseif (count($parameters) > 1) |
|
162 | - throw new \Exception('The data must have just one OTP code'); |
|
161 | + if (is_null($parameters)) { |
|
162 | + throw new \Exception('The data must be set'); |
|
163 | + } elseif (count($parameters) > 1) { |
|
164 | + throw new \Exception('The data must have just one OTP code'); |
|
165 | + } |
|
163 | 166 | |
164 | 167 | $mobile = $this->numbers; |
165 | - if ($mobile = []) |
|
166 | - throw new \Exception('The mobile number must be set'); |
|
167 | - if (count($mobile) > 1) |
|
168 | - throw new \Exception('The OTP code must send to just one mobile number'); |
|
168 | + if ($mobile = []) { |
|
169 | + throw new \Exception('The mobile number must be set'); |
|
170 | + } |
|
171 | + if (count($mobile) > 1) { |
|
172 | + throw new \Exception('The OTP code must send to just one mobile number'); |
|
173 | + } |
|
169 | 174 | |
170 | 175 | $templateId = $this->templateId; |
171 | - if (is_null($templateId)) |
|
172 | - throw new \Exception('The templateId must be set'); |
|
176 | + if (is_null($templateId)) { |
|
177 | + throw new \Exception('The templateId must be set'); |
|
178 | + } |
|
173 | 179 | |
174 | 180 | |
175 | - if (gettype($parameters[0]) != 'array') |
|
176 | - $checkParameter = $parameters[0]; |
|
177 | - else |
|
178 | - $checkParameter = $parameters; |
|
181 | + if (gettype($parameters[0]) != 'array') { |
|
182 | + $checkParameter = $parameters[0]; |
|
183 | + } else { |
|
184 | + $checkParameter = $parameters; |
|
185 | + } |
|
179 | 186 | |
180 | - if (!isset($checkParameter['name'])) |
|
181 | - throw new \Exception('The `name` parameter not defined in data'); |
|
182 | - if (!isset($checkParameter['value'])) |
|
183 | - throw new \Exception('The `value` parameter not defined in data'); |
|
187 | + if (!isset($checkParameter['name'])) { |
|
188 | + throw new \Exception('The `name` parameter not defined in data'); |
|
189 | + } |
|
190 | + if (!isset($checkParameter['value'])) { |
|
191 | + throw new \Exception('The `value` parameter not defined in data'); |
|
192 | + } |
|
184 | 193 | |
185 | 194 | return compact('parameters', 'mobile', 'templateId'); |
186 | 195 | } |
@@ -195,8 +204,9 @@ discard block |
||
195 | 204 | if (is_null($inputs['parameters'][0]['value'])) { |
196 | 205 | $inputs['parameters'][0]['value'] = rand(100000, 999999); |
197 | 206 | } |
198 | - } else |
|
199 | - $inputs['parameters'][0]['value'] = $pattern_code; |
|
207 | + } else { |
|
208 | + $inputs['parameters'][0]['value'] = $pattern_code; |
|
209 | + } |
|
200 | 210 | |
201 | 211 | } |
202 | 212 | |
@@ -231,19 +241,23 @@ discard block |
||
231 | 241 | private function setMessageExceptions() |
232 | 242 | { |
233 | 243 | $apiKey = config('sms.drivers.' . $this->drive . '.apiKey'); |
234 | - if ($apiKey == '') |
|
235 | - throw new \Exception('The apiKey of SMS.ir muse be set in config'); |
|
244 | + if ($apiKey == '') { |
|
245 | + throw new \Exception('The apiKey of SMS.ir muse be set in config'); |
|
246 | + } |
|
236 | 247 | |
237 | 248 | $this->url = config('sms.drivers.' . $this->drive . '.urlNormal'); |
238 | - if ($this->url == '') |
|
239 | - throw new \Exception('The url of SMS.ir muse be set in config'); |
|
249 | + if ($this->url == '') { |
|
250 | + throw new \Exception('The url of SMS.ir muse be set in config'); |
|
251 | + } |
|
240 | 252 | |
241 | 253 | $numbers = $this->numbers; |
242 | - if (count($numbers) < 1) |
|
243 | - throw new \Exception('The numbers of mobiles must be set'); |
|
254 | + if (count($numbers) < 1) { |
|
255 | + throw new \Exception('The numbers of mobiles must be set'); |
|
256 | + } |
|
244 | 257 | |
245 | - if ($this->from == '') |
|
246 | - throw new \Exception('The lineNumber of SMS.ir muse be set in config (set it in `from` key)'); |
|
258 | + if ($this->from == '') { |
|
259 | + throw new \Exception('The lineNumber of SMS.ir muse be set in config (set it in `from` key)'); |
|
260 | + } |
|
247 | 261 | |
248 | 262 | return compact('apiKey', 'numbers'); |
249 | 263 | } |