1313
1414class Client
1515{
16- const WRAPPER_VERSION = Config::WRAPPER_VERSION ;
16+ public const WRAPPER_VERSION = Config::WRAPPER_VERSION ;
1717
1818 /**
1919 * connect_timeout: (float, default=2) Float describing the number of
2020 * seconds to wait while trying to connect to a server. Use 0 to wait
2121 * indefinitely (the default behavior).
2222 */
23- const CONNECT_TIMEOUT = 'connect_timeout ' ;
23+ public const CONNECT_TIMEOUT = 'connect_timeout ' ;
2424
2525 /**
2626 * timeout: (float, default=15) Float describing the timeout of the
2727 * request in seconds. Use 0 to wait indefinitely (the default behavior).
2828 */
29- const TIMEOUT = 'timeout ' ;
29+ public const TIMEOUT = 'timeout ' ;
3030
3131 /**
3232 * proxy: (array, default=none) Array describing the proxy options used by guzzle client
3333 * See guzzle-http for specification.
3434 */
35- const PROXY = 'proxy ' ;
35+ public const PROXY = 'proxy ' ;
3636
3737 private $ apikey ;
3838 private $ apisecret ;
@@ -43,15 +43,24 @@ class Client
4343 private $ call = true ;
4444 private $ settings = [];
4545 private $ changed = false ;
46+ /**
47+ * @var int[]
48+ */
4649 private $ requestOptions = [
4750 self ::TIMEOUT => 15 ,
4851 self ::CONNECT_TIMEOUT => 2 ,
4952 ];
53+ /**
54+ * @var string[]
55+ */
5056 private $ smsResources = [
5157 'send ' ,
5258 'sms ' ,
5359 'sms-send ' ,
5460 ];
61+ /**
62+ * @var string[]
63+ */
5564 private $ dataAction = [
5665 'csverror/text:csv ' ,
5766 'csvdata/text:plain ' ,
@@ -60,10 +69,11 @@ class Client
6069
6170 /**
6271 * Client constructor requires:.
63- * @param string $key Mailjet API Key
64- * @param string|null $secret Mailjet API Secret
65- * @param bool $call performs the call or not
66- * @param array $settings
72+ *
73+ * @param string $key Mailjet API Key
74+ * @param string|null $secret Mailjet API Secret
75+ * @param bool $call performs the call or not
76+ * @param array $settings
6777 */
6878 public function __construct (string $ key , string $ secret = null , bool $ call = true , array $ settings = [])
6979 {
@@ -72,9 +82,10 @@ public function __construct(string $key, string $secret = null, bool $call = tru
7282
7383 /**
7484 * Trigger a POST request.
75- * @param array $resource Mailjet Resource/Action pair
76- * @param array $args Request arguments
77- * @param array $options
85+ *
86+ * @param array $resource Mailjet Resource/Action pair
87+ * @param array $args Request arguments
88+ * @param array $options
7889 * @return Response
7990 */
8091 public function post (array $ resource , array $ args = [], array $ options = []): Response
@@ -94,9 +105,10 @@ public function post(array $resource, array $args = [], array $options = []): Re
94105
95106 /**
96107 * Trigger a GET request.
97- * @param array $resource Mailjet Resource/Action pair
98- * @param array $args Request arguments
99- * @param array $options
108+ *
109+ * @param array $resource Mailjet Resource/Action pair
110+ * @param array $args Request arguments
111+ * @param array $options
100112 * @return Response
101113 */
102114 public function get (array $ resource , array $ args = [], array $ options = []): Response
@@ -116,9 +128,10 @@ public function get(array $resource, array $args = [], array $options = []): Res
116128
117129 /**
118130 * Trigger a POST request.
119- * @param array $resource Mailjet Resource/Action pair
120- * @param array $args Request arguments
121- * @param array $options
131+ *
132+ * @param array $resource Mailjet Resource/Action pair
133+ * @param array $args Request arguments
134+ * @param array $options
122135 * @return Response
123136 */
124137 public function put (array $ resource , array $ args = [], array $ options = []): Response
@@ -138,9 +151,10 @@ public function put(array $resource, array $args = [], array $options = []): Res
138151
139152 /**
140153 * Trigger a GET request.
141- * @param array $resource Mailjet Resource/Action pair
142- * @param array $args Request arguments
143- * @param array $options
154+ *
155+ * @param array $resource Mailjet Resource/Action pair
156+ * @param array $args Request arguments
157+ * @param array $options
144158 * @return Response
145159 */
146160 public function delete (array $ resource , array $ args = [], array $ options = []): Response
@@ -160,7 +174,8 @@ public function delete(array $resource, array $args = [], array $options = []):
160174
161175 /**
162176 * Sets if we need to use https or http protocol while using API Url.
163- * @param bool|mixed $bIsSecured True use https / false use http
177+ *
178+ * @param bool|mixed $bIsSecured True use https / false use http
164179 * @return bool true if we set value false otherwise
165180 */
166181 public function setSecureProtocol ($ bIsSecured = null ): bool
@@ -176,6 +191,7 @@ public function setSecureProtocol($bIsSecured = null): bool
176191
177192 /**
178193 * Set HTTP request Timeout.
194+ *
179195 * @param int $timeout
180196 */
181197 public function setTimeout (int $ timeout ): void
@@ -186,6 +202,7 @@ public function setTimeout(int $timeout): void
186202 /**
187203 * Set HTTP proxy options
188204 * See: http://docs.guzzlephp.org/en/stable/request-options.html#proxy.
205+ *
189206 * @param array $proxyArray
190207 */
191208 public function setHttpProxy (array $ proxyArray ): void
@@ -195,6 +212,7 @@ public function setHttpProxy(array $proxyArray): void
195212
196213 /**
197214 * Set HTTP connection Timeout.
215+ *
198216 * @param int $timeout
199217 */
200218 public function setConnectionTimeout (int $ timeout ): void
@@ -222,15 +240,16 @@ public function getConnectionTimeout(): ?int
222240
223241 /**
224242 * Add a HTTP request option.
243+ *
225244 * @param string $key
226- * @param mixed $value
245+ * @param mixed $value
227246 * [IMPORTANT]Default options will be overwritten
228247 * if such option is provided
229- * @see \GuzzleHttp\RequestOptions for a list of available request options.
248+ * @see \GuzzleHttp\RequestOptions for a list of available request options.
230249 */
231250 public function addRequestOption (string $ key , $ value ): void
232251 {
233- if (( null !== $ key) && (null !== $ value )) {
252+ if ($ key && (null !== $ value )) {
234253 $ this ->requestOptions [$ key ] = $ value ;
235254 }
236255 }
@@ -246,10 +265,11 @@ public function getRequestOptions(): array
246265
247266 /**
248267 * Set auth.
249- * @param string $key
268+ *
269+ * @param string $key
250270 * @param string|null $secret
251- * @param bool $call
252- * @param array $settings
271+ * @param bool $call
272+ * @param array $settings
253273 */
254274 public function setAuthentication (string $ key , ?string $ secret , bool $ call , array $ settings = []): void
255275 {
@@ -267,6 +287,7 @@ public function setAuthentication(string $key, ?string $secret, bool $call, arra
267287 $ this ->setSettings ();
268288 }
269289
290+ // phpcs:disable
270291 /**
271292 * Magic method to call a mailjet resource.
272293 * @param string $method Http method
@@ -289,7 +310,7 @@ private function _call(string $method, string $resource, string $action, array $
289310 $ contentType = 'application/json ' ;
290311 if ('csvdata/text:plain ' === $ action ) {
291312 $ contentType = 'text/plain ' ;
292- } else if ('csverror/text:csv ' === $ action ) {
313+ } elseif ('csverror/text:csv ' === $ action ) {
293314 $ contentType = 'text/csv ' ;
294315 }
295316
@@ -309,9 +330,11 @@ private function _call(string $method, string $resource, string $action, array $
309330 return $ request ->call ($ this ->call );
310331 }
311332
333+ // phpcs:enable
312334 /**
313335 * Build the base API url depending on wether user need a secure connection
314336 * or not.
337+ *
315338 * @return string the API url;
316339 */
317340 private function getApiUrl (): string
@@ -324,8 +347,9 @@ private function getApiUrl(): string
324347 /**
325348 * Checks that both parameters are strings, which means
326349 * that basic authentication will be required.
327- * @param mixed $key
328- * @param mixed $secret
350+ *
351+ * @param mixed $key
352+ * @param mixed $secret
329353 * @return bool flag
330354 */
331355 private function isBasicAuthentication ($ key , $ secret ): bool
@@ -335,10 +359,11 @@ private function isBasicAuthentication($key, $secret): bool
335359
336360 /**
337361 * Build the final call url without query strings.
338- * @param string $resource Mailjet resource
339- * @param string $action Mailjet resource action
340- * @param string $id mailjet resource id
341- * @param string $actionid mailjet resource actionid
362+ *
363+ * @param string $resource Mailjet resource
364+ * @param string $action Mailjet resource action
365+ * @param string $id mailjet resource id
366+ * @param string $actionid mailjet resource actionid
342367 * @return string final call url
343368 */
344369 private function buildURL (string $ resource , string $ action , string $ id , string $ actionid ): string
@@ -360,14 +385,15 @@ private function buildURL(string $resource, string $action, string $id, string $
360385
361386 /**
362387 * Temporary set the variables generating the url.
363- * @param array $options contain temporary modifications for the client
388+ *
389+ * @param array $options contain temporary modifications for the client
364390 * @param array $resource may contain the version linked to the resource
365391 */
366392 private function setOptions (array $ options , array $ resource ): void
367393 {
368394 if (isset ($ options ['version ' ])) {
369395 $ this ->version = $ options ['version ' ];
370- } else if (isset ($ resource [2 ])) {
396+ } elseif (isset ($ resource [2 ])) {
371397 $ this ->version = $ resource [2 ];
372398 }
373399
@@ -403,7 +429,8 @@ private function setSettings(): void
403429
404430 /**
405431 * Set a backup if the variables generating the url are change during a call.
406- * @param bool $call
432+ *
433+ * @param bool $call
407434 * @param array $settings
408435 */
409436 private function initSettings (bool $ call , array $ settings = []): void
0 commit comments