From 4abe78acad8334bfa27458f1322776dbb640d96a Mon Sep 17 00:00:00 2001 From: Oleksandr Mykhailenko Date: Sun, 11 Jun 2023 12:41:35 +0300 Subject: [PATCH] Code style changes only --- src/Mailjet/Client.php | 19 +--------------- src/Mailjet/Config.php | 12 +++++----- src/Mailjet/Request.php | 49 +++++++++++++++------------------------- src/Mailjet/Response.php | 10 +------- 4 files changed, 26 insertions(+), 64 deletions(-) diff --git a/src/Mailjet/Client.php b/src/Mailjet/Client.php index ae5234c..5d4ccac 100644 --- a/src/Mailjet/Client.php +++ b/src/Mailjet/Client.php @@ -60,7 +60,6 @@ class Client /** * Client constructor requires:. - * * @param string $key Mailjet API Key * @param string|null $secret Mailjet API Secret * @param bool $call performs the call or not @@ -73,7 +72,6 @@ public function __construct(string $key, string $secret = null, bool $call = tru /** * Trigger a POST request. - * * @param array $resource Mailjet Resource/Action pair * @param array $args Request arguments * @param array $options @@ -96,7 +94,6 @@ public function post(array $resource, array $args = [], array $options = []): Re /** * Trigger a GET request. - * * @param array $resource Mailjet Resource/Action pair * @param array $args Request arguments * @param array $options @@ -119,7 +116,6 @@ public function get(array $resource, array $args = [], array $options = []): Res /** * Trigger a POST request. - * * @param array $resource Mailjet Resource/Action pair * @param array $args Request arguments * @param array $options @@ -142,7 +138,6 @@ public function put(array $resource, array $args = [], array $options = []): Res /** * Trigger a GET request. - * * @param array $resource Mailjet Resource/Action pair * @param array $args Request arguments * @param array $options @@ -165,9 +160,7 @@ public function delete(array $resource, array $args = [], array $options = []): /** * Sets if we need to use https or http protocol while using API Url. - * * @param bool|mixed $bIsSecured True use https / false use http - * * @return bool true if we set value false otherwise */ public function setSecureProtocol($bIsSecured = null): bool @@ -229,12 +222,10 @@ public function getConnectionTimeout(): ?int /** * Add a HTTP request option. - * * @param string $key * @param mixed $value * [IMPORTANT]Default options will be overwritten * if such option is provided - * * @see \GuzzleHttp\RequestOptions for a list of available request options. */ public function addRequestOption(string $key, $value): void @@ -255,7 +246,6 @@ public function getRequestOptions(): array /** * Set auth. - * * @param string $key * @param string|null $secret * @param bool $call @@ -279,12 +269,10 @@ public function setAuthentication(string $key, ?string $secret, bool $call, arra /** * Magic method to call a mailjet resource. - * * @param string $method Http method * @param string $resource mailjet resource * @param string $action mailjet resource action * @param array $args Request arguments - * * @return Response server response */ private function _call(string $method, string $resource, string $action, array $args): Response @@ -296,7 +284,7 @@ private function _call(string $method, string $resource, string $action, array $ 'body' => 'GET' === $method ? null : '{}', ], array_change_key_case($args)); - $url = $this->buildURL($resource, $action, (string) $args['id'], $args['actionid']); + $url = $this->buildURL($resource, $action, (string)$args['id'], $args['actionid']); $contentType = 'application/json'; if ('csvdata/text:plain' === $action) { @@ -324,7 +312,6 @@ private function _call(string $method, string $resource, string $action, array $ /** * Build the base API url depending on wether user need a secure connection * or not. - * * @return string the API url; */ private function getApiUrl(): string @@ -337,7 +324,6 @@ private function getApiUrl(): string /** * Checks that both parameters are strings, which means * that basic authentication will be required. - * * @param mixed $key * @param mixed $secret * @return bool flag @@ -349,12 +335,10 @@ private function isBasicAuthentication($key, $secret): bool /** * Build the final call url without query strings. - * * @param string $resource Mailjet resource * @param string $action Mailjet resource action * @param string $id mailjet resource id * @param string $actionid mailjet resource actionid - * * @return string final call url */ private function buildURL(string $resource, string $action, string $id, string $actionid): string @@ -376,7 +360,6 @@ private function buildURL(string $resource, string $action, string $id, string $ /** * Temporary set the variables generating the url. - * * @param array $options contain temporary modifications for the client * @param array $resource may contain the version linked to the resource */ diff --git a/src/Mailjet/Config.php b/src/Mailjet/Config.php index 1b8dc3e..98ea271 100644 --- a/src/Mailjet/Config.php +++ b/src/Mailjet/Config.php @@ -13,10 +13,10 @@ class Config { - const WRAPPER_VERSION = 'v2.0.0'; - const USER_AGENT = 'mailjet-apiv3-php/'; - const MAIN_VERSION = 'v3'; - const MAIN_URL = 'api.mailjet.com'; - const SECURED = true; - const SMS_VERSION = 'v4'; + public const WRAPPER_VERSION = 'v2.0.0'; + public const USER_AGENT = 'mailjet-apiv3-php/'; + public const MAIN_VERSION = 'v3'; + public const MAIN_URL = 'api.mailjet.com'; + public const SECURED = true; + public const SMS_VERSION = 'v4'; } diff --git a/src/Mailjet/Request.php b/src/Mailjet/Request.php index 9fa7416..d3d734e 100644 --- a/src/Mailjet/Request.php +++ b/src/Mailjet/Request.php @@ -24,7 +24,7 @@ class Request { use GuzzleClientTrait; - + /** * @var string */ @@ -67,7 +67,6 @@ class Request /** * Build a new Http request. - * * @param array $auth [apikey, apisecret] * @param string $method http method * @param string $url call url @@ -77,13 +76,13 @@ class Request * @param array $requestOptions */ public function __construct( - array $auth, + array $auth, string $method, string $url, - array $filters, - $body, + array $filters, + $body, string $type, - array $requestOptions = [] + array $requestOptions = [] ) { $this->type = $type; $this->auth = $auth; @@ -95,19 +94,16 @@ public function __construct( $this->guzzleClient = new GuzzleClient( ['defaults' => [ 'headers' => [ - 'user-agent' => Config::USER_AGENT . PHP_VERSION.'/' . Client::WRAPPER_VERSION, - ], - ] + 'user-agent' => Config::USER_AGENT . PHP_VERSION . '/' . Client::WRAPPER_VERSION, + ], + ], ] ); } /** * Trigger the actual call - * TODO: DATA API. - * * @param $call - * * @return Response the call response */ public function call($call) @@ -125,7 +121,7 @@ public function call($call) if ($authArgsCount > 1) { $payload['auth'] = $this->auth; } else { - $headers['Authorization'] = 'Bearer '.$this->auth[0]; + $headers['Authorization'] = 'Bearer ' . $this->auth[0]; } $payload['headers'] = $headers; @@ -151,7 +147,6 @@ public function call($call) /** * Filters getters. - * * @return array Request filters */ public function getFilters(): array @@ -161,7 +156,6 @@ public function getFilters(): array /** * Http method getter. - * * @return string Request method */ public function getMethod(): string @@ -171,7 +165,6 @@ public function getMethod(): string /** * Call Url getter. - * * @return string Request Url */ public function getUrl(): string @@ -181,7 +174,6 @@ public function getUrl(): string /** * Request body getter. - * * @return array request body */ public function getBody(): array @@ -191,7 +183,6 @@ public function getBody(): array /** * Auth getter. to discuss. - * * @return array Request auth */ public function getAuth(): array @@ -201,9 +192,8 @@ public function getAuth(): array /** * @param RequestInterface $request Request to send - * @param array $options Request options to apply to the given + * @param array $options Request options to apply to the given * request and to the transfer. - * * @throws GuzzleException */ public function send(RequestInterface $request, array $options = []): ResponseInterface @@ -213,9 +203,7 @@ public function send(RequestInterface $request, array $options = []): ResponseIn /** * @param RequestInterface $request - * * @return ResponseInterface - * * @throws \Psr\Http\Client\ClientExceptionInterface */ public function sendRequest(RequestInterface $request): ResponseInterface @@ -225,19 +213,18 @@ public function sendRequest(RequestInterface $request): ResponseInterface /** * @param RequestInterface $request Request to send - * @param array $options Request options to apply to the given + * @param array $options Request options to apply to the given * request and to the transfer. */ public function sendAsync(RequestInterface $request, array $options = []): PromiseInterface { - return $this->guzzleClient->sendAsync($request,$options); + return $this->guzzleClient->sendAsync($request, $options); } /** - * @param string $method HTTP method. - * @param string|UriInterface $uri URI object or string. - * @param array $options Request options to apply. - * + * @param string $method HTTP method. + * @param string|UriInterface $uri URI object or string. + * @param array $options Request options to apply. * @throws GuzzleException */ public function request(string $method, $uri, array $options = []): ResponseInterface @@ -246,9 +233,9 @@ public function request(string $method, $uri, array $options = []): ResponseInte } /** - * @param string $method HTTP method - * @param string|UriInterface $uri URI object or string. - * @param array $options Request options to apply. + * @param string $method HTTP method + * @param string|UriInterface $uri URI object or string. + * @param array $options Request options to apply. */ public function requestAsync(string $method, $uri, array $options = []): PromiseInterface { diff --git a/src/Mailjet/Response.php b/src/Mailjet/Response.php index 346738b..3c64938 100644 --- a/src/Mailjet/Response.php +++ b/src/Mailjet/Response.php @@ -42,8 +42,7 @@ class Response /** * Construct a Mailjet response. - * - * @param Request $request Mailjet actual request + * @param Request $request Mailjet actual request * @param ResponseInterface|null $response Guzzle response */ public function __construct(Request $request, ?ResponseInterface $response) @@ -61,7 +60,6 @@ public function __construct(Request $request, ?ResponseInterface $response) /** * Status Getter * return the http status code. - * * @return int|null status */ public function getStatus(): ?int @@ -81,7 +79,6 @@ public function getBody(): array /** * Data Getter * The data returned by the mailjet call. - * * @return array data */ public function getData(): array @@ -101,7 +98,6 @@ public function getCount(): ?int /** * Error Reason getter * return the resulting error message. - * * @return string|null */ public function getReasonPhrase(): ?string @@ -112,7 +108,6 @@ public function getReasonPhrase(): ?string /** * Total getter * return the total count of all results. - * * @return int|null count */ public function getTotal(): ?int @@ -122,7 +117,6 @@ public function getTotal(): ?int /** * Success getter. - * * @return bool|null true is return code is 2** */ public function success(): ?bool @@ -137,9 +131,7 @@ public function getRequest(): Request /** * Decodes a mailjet string response to an object representing that response. - * * @param string $body The mailjet response as string - * * @return array Object representing the mailjet response */ protected function decodeBody(string $body): array