From aeeceafbb491c6a5969aedb85f6676b68f10daf8 Mon Sep 17 00:00:00 2001 From: yedincisenol Date: Sun, 27 Oct 2019 14:24:02 +0000 Subject: [PATCH] Apply fixes from StyleCI --- src/Config/Sms.php | 6 +++--- src/Drivers/Iletimerkezi.php | 10 ++++++---- src/Drivers/Verimor.php | 27 ++++++++++++++------------- test.php | 4 ++-- 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/Config/Sms.php b/src/Config/Sms.php index fb0e46b..577646e 100644 --- a/src/Config/Sms.php +++ b/src/Config/Sms.php @@ -17,7 +17,7 @@ ], 'Verimor' => [ 'request_endpoint' => 'http://sms.verimor.com.tr/v2/send.json', - 'username' => 'username', - 'password' => 'password' - ] + 'username' => 'username', + 'password' => 'password', + ], ]; diff --git a/src/Drivers/Iletimerkezi.php b/src/Drivers/Iletimerkezi.php index 662a7fd..abca9c3 100644 --- a/src/Drivers/Iletimerkezi.php +++ b/src/Drivers/Iletimerkezi.php @@ -13,10 +13,11 @@ class Iletimerkezi extends Sms * @param $numbers * @param $header * - * @return mixed * @throws DriverSmsSendFailException * @throws \GuzzleHttp\Exception\GuzzleException * @throws \yedincisenol\Sms\Exceptions\DriverConfigurationException + * + * @return mixed */ public function send($message, $numbers, $header) { @@ -32,19 +33,20 @@ public function send($message, $numbers, $header) 'text' => $message, ], ]); } catch (\Exception $e) { - $this->checkResponse($e->getResponse()); + $this->checkResponse($e->getResponse()); } } /** * @param $response + * * @throws DriverSmsSendFailException */ protected function checkResponse($response) { - $xml = simplexml_load_string((string) $response->getBody(), "SimpleXMLElement", LIBXML_NOCDATA); + $xml = simplexml_load_string((string) $response->getBody(), 'SimpleXMLElement', LIBXML_NOCDATA); $json = json_encode($xml); - $array = json_decode($json,TRUE); + $array = json_decode($json, true); throw new DriverSmsSendFailException($array['status']['message'], $array['status']['code']); } diff --git a/src/Drivers/Verimor.php b/src/Drivers/Verimor.php index e1b7a54..ed19f54 100644 --- a/src/Drivers/Verimor.php +++ b/src/Drivers/Verimor.php @@ -3,8 +3,6 @@ namespace yedincisenol\Sms\Drivers; use GuzzleHttp\Exception\RequestException; -use http\Client\Response; -use Psr\Http\Message\ResponseInterface; use yedincisenol\Sms\Exceptions\DriverConfigurationException; class Verimor extends Sms @@ -13,7 +11,7 @@ class Verimor extends Sms * @var array Required config fields */ protected $requiredConfig = [ - 'username', 'password' + 'username', 'password', ]; /** @@ -21,26 +19,28 @@ class Verimor extends Sms * @param $numbers * @param $header * - * @return void * @throws \yedincisenol\Sms\Exceptions\DriverConfigurationException * @throws \GuzzleHttp\Exception\GuzzleException + * + * @return void */ public function send($message, $numbers, $header) { $this->validateConfig(); + try { $this->httpClient->request('POST', $this->config['request_endpoint'], [ 'json' => [ - 'username' => $this->config['username'], - 'password' => $this->config['password'], + 'username' => $this->config['username'], + 'password' => $this->config['password'], 'source_addr' => $header, - 'messages' => [ + 'messages' => [ [ - 'msg' => $message, - 'dest' => implode(',', $numbers) - ] - ] - ] + 'msg' => $message, + 'dest' => implode(',', $numbers), + ], + ], + ], ]); } catch (RequestException $exception) { $this->checkResponse($exception->getCode()); @@ -49,6 +49,7 @@ public function send($message, $numbers, $header) /** * @param $responseCode + * * @throws DriverConfigurationException */ protected function checkResponse($responseCode) @@ -62,4 +63,4 @@ protected function checkResponse($responseCode) break; } } -} \ No newline at end of file +} diff --git a/test.php b/test.php index 30fdd53..7a0dbc2 100644 --- a/test.php +++ b/test.php @@ -26,7 +26,7 @@ $verimor = new \yedincisenol\Sms\Sms('Verimor', [ 'username' => 'username', - 'password' => 'password' + 'password' => 'password', ]); -$verimor->send('Selam', ['00905459196661'], 'HEADER'); \ No newline at end of file +$verimor->send('Selam', ['00905459196661'], 'HEADER');