@@ -2,7 +2,6 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace seregazhuk\SmsIntel; |
| 4 | 4 | |
| 5 | -use seregazhuk\SmsIntel\Adapters\GuzzleHttpAdapter; |
|
| 6 | 5 | use seregazhuk\SmsIntel\Contracts\RequestInterface; |
| 7 | 6 | |
| 8 | 7 | class Sender |
@@ -27,9 +27,9 @@ discard block |
||
| 27 | 27 | * @param array $params |
| 28 | 28 | * @return array|null |
| 29 | 29 | */ |
| 30 | - public function send($to, $from, $message, $params = []) |
|
| 30 | + public function send($to, $from, $message, $params = [ ]) |
|
| 31 | 31 | { |
| 32 | - $to = is_array($to) ? $to : [$to]; |
|
| 32 | + $to = is_array($to) ? $to : [ $to ]; |
|
| 33 | 33 | |
| 34 | 34 | $requestParams = array_merge( |
| 35 | 35 | [ |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | public function cancel($smsId) |
| 50 | 50 | { |
| 51 | - return $this->request->exec('cancel', ['smsid' => $smsId]); |
|
| 51 | + return $this->request->exec('cancel', [ 'smsid' => $smsId ]); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | public function getReportBySms($smsId) |
| 94 | 94 | { |
| 95 | - return $this->request->exec('report', ['smsid' => $smsId]); |
|
| 95 | + return $this->request->exec('report', [ 'smsid' => $smsId ]); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -8,68 +8,68 @@ |
||
| 8 | 8 | |
| 9 | 9 | class GuzzleHttpAdapter implements HttpInterface{ |
| 10 | 10 | |
| 11 | - /** |
|
| 12 | - * @var Client |
|
| 13 | - */ |
|
| 14 | - protected $client; |
|
| 11 | + /** |
|
| 12 | + * @var Client |
|
| 13 | + */ |
|
| 14 | + protected $client; |
|
| 15 | 15 | |
| 16 | - public function __construct() |
|
| 17 | - { |
|
| 18 | - $this->client = new Client(); |
|
| 19 | - } |
|
| 16 | + public function __construct() |
|
| 17 | + { |
|
| 18 | + $this->client = new Client(); |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @param $uri |
|
| 23 | - * @param array $params |
|
| 24 | - * @return array |
|
| 25 | - */ |
|
| 26 | - public function get($uri, $params = []) |
|
| 27 | - { |
|
| 28 | - if(!empty($params)){ |
|
| 29 | - $uri .= '?'. http_build_query($params); |
|
| 30 | - } |
|
| 31 | - $response = $this |
|
| 32 | - ->client |
|
| 33 | - ->get($uri) |
|
| 34 | - ->send(); |
|
| 21 | + /** |
|
| 22 | + * @param $uri |
|
| 23 | + * @param array $params |
|
| 24 | + * @return array |
|
| 25 | + */ |
|
| 26 | + public function get($uri, $params = []) |
|
| 27 | + { |
|
| 28 | + if(!empty($params)){ |
|
| 29 | + $uri .= '?'. http_build_query($params); |
|
| 30 | + } |
|
| 31 | + $response = $this |
|
| 32 | + ->client |
|
| 33 | + ->get($uri) |
|
| 34 | + ->send(); |
|
| 35 | 35 | |
| 36 | - return $this->parseResponse($response); |
|
| 37 | - } |
|
| 36 | + return $this->parseResponse($response); |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @param string $uri |
|
| 41 | - * @param array $body |
|
| 42 | - * @return array |
|
| 43 | - */ |
|
| 44 | - public function post($uri, $body) |
|
| 45 | - { |
|
| 46 | - $response = $this |
|
| 47 | - ->client |
|
| 48 | - ->post($uri, [], $body) |
|
| 49 | - ->send(); |
|
| 50 | - return $this->parseResponse($response); |
|
| 51 | - } |
|
| 39 | + /** |
|
| 40 | + * @param string $uri |
|
| 41 | + * @param array $body |
|
| 42 | + * @return array |
|
| 43 | + */ |
|
| 44 | + public function post($uri, $body) |
|
| 45 | + { |
|
| 46 | + $response = $this |
|
| 47 | + ->client |
|
| 48 | + ->post($uri, [], $body) |
|
| 49 | + ->send(); |
|
| 50 | + return $this->parseResponse($response); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * @param string $url |
|
| 55 | - * @return $this |
|
| 56 | - */ |
|
| 57 | - public function setBaseUrl($url) |
|
| 58 | - { |
|
| 59 | - $this->client->setBaseUrl($url); |
|
| 53 | + /** |
|
| 54 | + * @param string $url |
|
| 55 | + * @return $this |
|
| 56 | + */ |
|
| 57 | + public function setBaseUrl($url) |
|
| 58 | + { |
|
| 59 | + $this->client->setBaseUrl($url); |
|
| 60 | 60 | |
| 61 | - return $this; |
|
| 62 | - } |
|
| 61 | + return $this; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 64 | + /** |
|
| 65 | 65 | * Parses XML from response and returns it as an array |
| 66 | 66 | * |
| 67 | - * @param Response $response |
|
| 68 | - * @return array |
|
| 69 | - */ |
|
| 70 | - protected function parseResponse(Response $response) |
|
| 71 | - { |
|
| 72 | - $xml = simplexml_load_string($response->getBody(true)); |
|
| 67 | + * @param Response $response |
|
| 68 | + * @return array |
|
| 69 | + */ |
|
| 70 | + protected function parseResponse(Response $response) |
|
| 71 | + { |
|
| 72 | + $xml = simplexml_load_string($response->getBody(true)); |
|
| 73 | 73 | return (array)$xml->children(); |
| 74 | - } |
|
| 74 | + } |
|
| 75 | 75 | } |
| 76 | 76 | \ No newline at end of file |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | use Guzzle\Http\Message\Response; |
| 7 | 7 | use seregazhuk\SmsIntel\Contracts\HttpInterface; |
| 8 | 8 | |
| 9 | -class GuzzleHttpAdapter implements HttpInterface{ |
|
| 9 | +class GuzzleHttpAdapter implements HttpInterface { |
|
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | 12 | * @var Client |
@@ -23,10 +23,10 @@ discard block |
||
| 23 | 23 | * @param array $params |
| 24 | 24 | * @return array |
| 25 | 25 | */ |
| 26 | - public function get($uri, $params = []) |
|
| 26 | + public function get($uri, $params = [ ]) |
|
| 27 | 27 | { |
| 28 | - if(!empty($params)){ |
|
| 29 | - $uri .= '?'. http_build_query($params); |
|
| 28 | + if (!empty($params)) { |
|
| 29 | + $uri .= '?' . http_build_query($params); |
|
| 30 | 30 | } |
| 31 | 31 | $response = $this |
| 32 | 32 | ->client |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | { |
| 46 | 46 | $response = $this |
| 47 | 47 | ->client |
| 48 | - ->post($uri, [], $body) |
|
| 48 | + ->post($uri, [ ], $body) |
|
| 49 | 49 | ->send(); |
| 50 | 50 | return $this->parseResponse($response); |
| 51 | 51 | } |
@@ -31,9 +31,9 @@ |
||
| 31 | 31 | */ |
| 32 | 32 | public function toXml() |
| 33 | 33 | { |
| 34 | - return $this->initDom() |
|
| 35 | - ->createParamsNodes() |
|
| 36 | - ->getXml(); |
|
| 34 | + return $this->initDom() |
|
| 35 | + ->createParamsNodes() |
|
| 36 | + ->getXml(); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
@@ -38,7 +38,7 @@ |
||
| 38 | 38 | * @param array $params |
| 39 | 39 | * @return array|null |
| 40 | 40 | */ |
| 41 | - public function exec($action, $params = []) |
|
| 41 | + public function exec($action, $params = [ ]) |
|
| 42 | 42 | { |
| 43 | 43 | $endPoint = $this->makeEndPoint($action); |
| 44 | 44 | $requestBody = $this->createRequestBody($params); |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | */ |
| 31 | 31 | protected static function checkCredentials($login, $password) |
| 32 | 32 | { |
| 33 | - if(empty($login) || empty($password)) { |
|
| 33 | + if (empty($login) || empty($password)) { |
|
| 34 | 34 | throw new AuthException('You must provide login and password to send messages!'); |
| 35 | 35 | } |
| 36 | 36 | } |
@@ -4,23 +4,23 @@ |
||
| 4 | 4 | |
| 5 | 5 | interface HttpInterface { |
| 6 | 6 | |
| 7 | - /** |
|
| 8 | - * @param $uri |
|
| 9 | - * @param array $params |
|
| 10 | - * @return array |
|
| 11 | - */ |
|
| 12 | - public function get($uri, $params = []); |
|
| 7 | + /** |
|
| 8 | + * @param $uri |
|
| 9 | + * @param array $params |
|
| 10 | + * @return array |
|
| 11 | + */ |
|
| 12 | + public function get($uri, $params = []); |
|
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * @param $uri |
|
| 16 | - * @param $body |
|
| 17 | - * @return array |
|
| 18 | - */ |
|
| 19 | - public function post($uri, $body); |
|
| 14 | + /** |
|
| 15 | + * @param $uri |
|
| 16 | + * @param $body |
|
| 17 | + * @return array |
|
| 18 | + */ |
|
| 19 | + public function post($uri, $body); |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @param string $url |
|
| 23 | - * @return $this |
|
| 24 | - */ |
|
| 25 | - public function setBaseUrl($url); |
|
| 21 | + /** |
|
| 22 | + * @param string $url |
|
| 23 | + * @return $this |
|
| 24 | + */ |
|
| 25 | + public function setBaseUrl($url); |
|
| 26 | 26 | } |
| 27 | 27 | \ No newline at end of file |
@@ -9,7 +9,7 @@ |
||
| 9 | 9 | * @param array $params |
| 10 | 10 | * @return array |
| 11 | 11 | */ |
| 12 | - public function get($uri, $params = []); |
|
| 12 | + public function get($uri, $params = [ ]); |
|
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | 15 | * @param $uri |
@@ -4,10 +4,10 @@ |
||
| 4 | 4 | |
| 5 | 5 | interface RequestInterface { |
| 6 | 6 | |
| 7 | - /** |
|
| 8 | - * Send the request to API |
|
| 9 | - * @param $uri |
|
| 10 | - * @param $params |
|
| 11 | - */ |
|
| 12 | - public function exec($uri, $params); |
|
| 7 | + /** |
|
| 8 | + * Send the request to API |
|
| 9 | + * @param $uri |
|
| 10 | + * @param $params |
|
| 11 | + */ |
|
| 12 | + public function exec($uri, $params); |
|
| 13 | 13 | } |
| 14 | 14 | \ No newline at end of file |