@@ -86,7 +86,7 @@ |
||
| 86 | 86 | * |
| 87 | 87 | * @param $code - the response code |
| 88 | 88 | * @param null $message - an optional message aside from the default ones |
| 89 | - * @param null $provider - the SMS provider used. Should only be enabled during debug mode. |
|
| 89 | + * @param string $provider - the SMS provider used. Should only be enabled during debug mode. |
|
| 90 | 90 | */ |
| 91 | 91 | protected function response($code, $message = null, $provider) |
| 92 | 92 | { |
@@ -1,10 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace ridvanbaluyos\sms; |
| 3 | 3 | |
| 4 | -use ridvanbaluyos\sms\providers\PromoTexter; |
|
| 5 | -use ridvanbaluyos\sms\providers\RisingTide; |
|
| 6 | -use ridvanbaluyos\sms\providers\Semaphore; |
|
| 7 | -use ridvanbaluyos\sms\providers\Chikka; |
|
| 8 | 4 | use Noodlehaus\Config as Config; |
| 9 | 5 | |
| 10 | 6 | /** |
@@ -16,23 +16,23 @@ discard block |
||
| 16 | 16 | /** |
| 17 | 17 | * @var SmsProviderServicesInterface |
| 18 | 18 | */ |
| 19 | - private $smsProvider; |
|
| 19 | + private $smsProvider; |
|
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * Sms constructor. |
| 23 | 23 | * @param SmsProviderServicesInterface|null $smsProvider |
| 24 | 24 | */ |
| 25 | - public function __construct(SmsProviderServicesInterface $smsProvider = null) |
|
| 26 | - { |
|
| 27 | - // If no provider is specified, randomize by distribution percentage. |
|
| 28 | - if (is_null($smsProvider)) { |
|
| 25 | + public function __construct(SmsProviderServicesInterface $smsProvider = null) |
|
| 26 | + { |
|
| 27 | + // If no provider is specified, randomize by distribution percentage. |
|
| 28 | + if (is_null($smsProvider)) { |
|
| 29 | 29 | $provider = 'ridvanbaluyos\\sms\\providers\\' . $this->randomizeProvider(); |
| 30 | 30 | $this->smsProvider = new $provider(); |
| 31 | 31 | } else { |
| 32 | 32 | $this->smsProvider = $smsProvider; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - } |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * This function sends the SMS. |
@@ -40,11 +40,11 @@ discard block |
||
| 40 | 40 | * @param $phoneNumber - the mobile number |
| 41 | 41 | * @param $message - the message |
| 42 | 42 | */ |
| 43 | - public function send($phoneNumber, $message) |
|
| 44 | - { |
|
| 45 | - $phoneNumber = $this->prepareNumber($phoneNumber); |
|
| 46 | - $this->smsProvider->send($phoneNumber, $message . ' via ' . $this->smsProvider->className); |
|
| 47 | - } |
|
| 43 | + public function send($phoneNumber, $message) |
|
| 44 | + { |
|
| 45 | + $phoneNumber = $this->prepareNumber($phoneNumber); |
|
| 46 | + $this->smsProvider->send($phoneNumber, $message . ' via ' . $this->smsProvider->className); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * This function randomizes the SMS providers. Make sure that the total |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * |
| 54 | 54 | * @return string $result - the lucky SMS provider |
| 55 | 55 | */ |
| 56 | - private function randomizeProvider() |
|
| 56 | + private function randomizeProvider() |
|
| 57 | 57 | { |
| 58 | 58 | $providers = Config::load(__DIR__ . '/config/distribution.json'); |
| 59 | 59 | |
@@ -7,5 +7,5 @@ |
||
| 7 | 7 | */ |
| 8 | 8 | interface SmsProviderServicesInterface |
| 9 | 9 | { |
| 10 | - public function send($phoneNumber, $message); |
|
| 10 | + public function send($phoneNumber, $message); |
|
| 11 | 11 | } |
| 12 | 12 | \ No newline at end of file |
@@ -30,9 +30,9 @@ discard block |
||
| 30 | 30 | * @param $phoneNumber |
| 31 | 31 | * @param $message |
| 32 | 32 | */ |
| 33 | - public function send($phoneNumber, $message) |
|
| 34 | - { |
|
| 35 | - try { |
|
| 33 | + public function send($phoneNumber, $message) |
|
| 34 | + { |
|
| 35 | + try { |
|
| 36 | 36 | $conf = Config::load(__DIR__ . '/../config/providers.json')[$this->className]; |
| 37 | 37 | $query = [ |
| 38 | 38 | 'senderid' => $conf['senderid'], |
@@ -59,5 +59,5 @@ discard block |
||
| 59 | 59 | } catch (Exception $e) { |
| 60 | 60 | |
| 61 | 61 | } |
| 62 | - } |
|
| 62 | + } |
|
| 63 | 63 | } |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | $query = [ |
| 38 | 38 | 'senderid' => $conf['senderid'], |
| 39 | 39 | 'clientid' => $conf['clientid'], |
| 40 | - 'passkey' => $conf['passkey'] , |
|
| 40 | + 'passkey' => $conf['passkey'], |
|
| 41 | 41 | 'msisdn' => $phoneNumber, |
| 42 | 42 | 'message' => base64_encode($message), |
| 43 | 43 | 'dlr-call' => $conf['dlr-call'], |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | $url = $conf['url'] . '?' . http_build_query($query); |
| 48 | 48 | |
| 49 | 49 | $ch = curl_init(); |
| 50 | - curl_setopt($ch,CURLOPT_URL,$url); |
|
| 50 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
| 51 | 51 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
| 52 | 52 | curl_setopt($ch, CURLOPT_TIMEOUT, 240); |
| 53 | 53 | $result = curl_exec($ch); |
@@ -44,7 +44,7 @@ |
||
| 44 | 44 | $url = $conf['url'] . '?' . http_build_query($query); |
| 45 | 45 | |
| 46 | 46 | $ch = curl_init(); |
| 47 | - curl_setopt($ch,CURLOPT_URL,$url); |
|
| 47 | + curl_setopt($ch, CURLOPT_URL, $url); |
|
| 48 | 48 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
| 49 | 49 | curl_setopt($ch, CURLOPT_TIMEOUT, 240); |
| 50 | 50 | $result = curl_exec($ch); |
@@ -32,8 +32,8 @@ discard block |
||
| 32 | 32 | * @param $phoneNumber |
| 33 | 33 | * @param $message |
| 34 | 34 | */ |
| 35 | - public function send($phoneNumber, $message) |
|
| 36 | - { |
|
| 35 | + public function send($phoneNumber, $message) |
|
| 36 | + { |
|
| 37 | 37 | try { |
| 38 | 38 | $conf = Config::load(__DIR__ . '/../config/providers.json')[$this->className]; |
| 39 | 39 | |
@@ -76,5 +76,5 @@ discard block |
||
| 76 | 76 | } catch (Exception $e) { |
| 77 | 77 | |
| 78 | 78 | } |
| 79 | - } |
|
| 79 | + } |
|
| 80 | 80 | } |
| 81 | 81 | \ No newline at end of file |