@@ -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 | } |