Skip to content

Commit 34bac76

Browse files
Merge pull request #271 from mailjet/code-styles-adj
Code style changes only
2 parents 6125a15 + 4abe78a commit 34bac76

4 files changed

Lines changed: 26 additions & 64 deletions

File tree

src/Mailjet/Client.php

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ class Client
6060

6161
/**
6262
* Client constructor requires:.
63-
*
6463
* @param string $key Mailjet API Key
6564
* @param string|null $secret Mailjet API Secret
6665
* @param bool $call performs the call or not
@@ -73,7 +72,6 @@ public function __construct(string $key, string $secret = null, bool $call = tru
7372

7473
/**
7574
* Trigger a POST request.
76-
*
7775
* @param array $resource Mailjet Resource/Action pair
7876
* @param array $args Request arguments
7977
* @param array $options
@@ -96,7 +94,6 @@ public function post(array $resource, array $args = [], array $options = []): Re
9694

9795
/**
9896
* Trigger a GET request.
99-
*
10097
* @param array $resource Mailjet Resource/Action pair
10198
* @param array $args Request arguments
10299
* @param array $options
@@ -119,7 +116,6 @@ public function get(array $resource, array $args = [], array $options = []): Res
119116

120117
/**
121118
* Trigger a POST request.
122-
*
123119
* @param array $resource Mailjet Resource/Action pair
124120
* @param array $args Request arguments
125121
* @param array $options
@@ -142,7 +138,6 @@ public function put(array $resource, array $args = [], array $options = []): Res
142138

143139
/**
144140
* Trigger a GET request.
145-
*
146141
* @param array $resource Mailjet Resource/Action pair
147142
* @param array $args Request arguments
148143
* @param array $options
@@ -165,9 +160,7 @@ public function delete(array $resource, array $args = [], array $options = []):
165160

166161
/**
167162
* Sets if we need to use https or http protocol while using API Url.
168-
*
169163
* @param bool|mixed $bIsSecured True use https / false use http
170-
*
171164
* @return bool true if we set value false otherwise
172165
*/
173166
public function setSecureProtocol($bIsSecured = null): bool
@@ -229,12 +222,10 @@ public function getConnectionTimeout(): ?int
229222

230223
/**
231224
* Add a HTTP request option.
232-
*
233225
* @param string $key
234226
* @param mixed $value
235227
* [IMPORTANT]Default options will be overwritten
236228
* if such option is provided
237-
*
238229
* @see \GuzzleHttp\RequestOptions for a list of available request options.
239230
*/
240231
public function addRequestOption(string $key, $value): void
@@ -255,7 +246,6 @@ public function getRequestOptions(): array
255246

256247
/**
257248
* Set auth.
258-
*
259249
* @param string $key
260250
* @param string|null $secret
261251
* @param bool $call
@@ -279,12 +269,10 @@ public function setAuthentication(string $key, ?string $secret, bool $call, arra
279269

280270
/**
281271
* Magic method to call a mailjet resource.
282-
*
283272
* @param string $method Http method
284273
* @param string $resource mailjet resource
285274
* @param string $action mailjet resource action
286275
* @param array $args Request arguments
287-
*
288276
* @return Response server response
289277
*/
290278
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 $
296284
'body' => 'GET' === $method ? null : '{}',
297285
], array_change_key_case($args));
298286

299-
$url = $this->buildURL($resource, $action, (string) $args['id'], $args['actionid']);
287+
$url = $this->buildURL($resource, $action, (string)$args['id'], $args['actionid']);
300288

301289
$contentType = 'application/json';
302290
if ('csvdata/text:plain' === $action) {
@@ -324,7 +312,6 @@ private function _call(string $method, string $resource, string $action, array $
324312
/**
325313
* Build the base API url depending on wether user need a secure connection
326314
* or not.
327-
*
328315
* @return string the API url;
329316
*/
330317
private function getApiUrl(): string
@@ -337,7 +324,6 @@ private function getApiUrl(): string
337324
/**
338325
* Checks that both parameters are strings, which means
339326
* that basic authentication will be required.
340-
*
341327
* @param mixed $key
342328
* @param mixed $secret
343329
* @return bool flag
@@ -349,12 +335,10 @@ private function isBasicAuthentication($key, $secret): bool
349335

350336
/**
351337
* Build the final call url without query strings.
352-
*
353338
* @param string $resource Mailjet resource
354339
* @param string $action Mailjet resource action
355340
* @param string $id mailjet resource id
356341
* @param string $actionid mailjet resource actionid
357-
*
358342
* @return string final call url
359343
*/
360344
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 $
376360

377361
/**
378362
* Temporary set the variables generating the url.
379-
*
380363
* @param array $options contain temporary modifications for the client
381364
* @param array $resource may contain the version linked to the resource
382365
*/

src/Mailjet/Config.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313

1414
class Config
1515
{
16-
const WRAPPER_VERSION = 'v2.0.0';
17-
const USER_AGENT = 'mailjet-apiv3-php/';
18-
const MAIN_VERSION = 'v3';
19-
const MAIN_URL = 'api.mailjet.com';
20-
const SECURED = true;
21-
const SMS_VERSION = 'v4';
16+
public const WRAPPER_VERSION = 'v2.0.0';
17+
public const USER_AGENT = 'mailjet-apiv3-php/';
18+
public const MAIN_VERSION = 'v3';
19+
public const MAIN_URL = 'api.mailjet.com';
20+
public const SECURED = true;
21+
public const SMS_VERSION = 'v4';
2222
}

src/Mailjet/Request.php

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
class Request
2525
{
2626
use GuzzleClientTrait;
27-
27+
2828
/**
2929
* @var string
3030
*/
@@ -67,7 +67,6 @@ class Request
6767

6868
/**
6969
* Build a new Http request.
70-
*
7170
* @param array $auth [apikey, apisecret]
7271
* @param string $method http method
7372
* @param string $url call url
@@ -77,13 +76,13 @@ class Request
7776
* @param array $requestOptions
7877
*/
7978
public function __construct(
80-
array $auth,
79+
array $auth,
8180
string $method,
8281
string $url,
83-
array $filters,
84-
$body,
82+
array $filters,
83+
$body,
8584
string $type,
86-
array $requestOptions = []
85+
array $requestOptions = []
8786
) {
8887
$this->type = $type;
8988
$this->auth = $auth;
@@ -95,19 +94,16 @@ public function __construct(
9594
$this->guzzleClient = new GuzzleClient(
9695
['defaults' => [
9796
'headers' => [
98-
'user-agent' => Config::USER_AGENT . PHP_VERSION.'/' . Client::WRAPPER_VERSION,
99-
],
100-
]
97+
'user-agent' => Config::USER_AGENT . PHP_VERSION . '/' . Client::WRAPPER_VERSION,
98+
],
99+
],
101100
]
102101
);
103102
}
104103

105104
/**
106105
* Trigger the actual call
107-
* TODO: DATA API.
108-
*
109106
* @param $call
110-
*
111107
* @return Response the call response
112108
*/
113109
public function call($call)
@@ -125,7 +121,7 @@ public function call($call)
125121
if ($authArgsCount > 1) {
126122
$payload['auth'] = $this->auth;
127123
} else {
128-
$headers['Authorization'] = 'Bearer '.$this->auth[0];
124+
$headers['Authorization'] = 'Bearer ' . $this->auth[0];
129125
}
130126

131127
$payload['headers'] = $headers;
@@ -151,7 +147,6 @@ public function call($call)
151147

152148
/**
153149
* Filters getters.
154-
*
155150
* @return array Request filters
156151
*/
157152
public function getFilters(): array
@@ -161,7 +156,6 @@ public function getFilters(): array
161156

162157
/**
163158
* Http method getter.
164-
*
165159
* @return string Request method
166160
*/
167161
public function getMethod(): string
@@ -171,7 +165,6 @@ public function getMethod(): string
171165

172166
/**
173167
* Call Url getter.
174-
*
175168
* @return string Request Url
176169
*/
177170
public function getUrl(): string
@@ -181,7 +174,6 @@ public function getUrl(): string
181174

182175
/**
183176
* Request body getter.
184-
*
185177
* @return array request body
186178
*/
187179
public function getBody(): array
@@ -191,7 +183,6 @@ public function getBody(): array
191183

192184
/**
193185
* Auth getter. to discuss.
194-
*
195186
* @return array Request auth
196187
*/
197188
public function getAuth(): array
@@ -201,9 +192,8 @@ public function getAuth(): array
201192

202193
/**
203194
* @param RequestInterface $request Request to send
204-
* @param array $options Request options to apply to the given
195+
* @param array $options Request options to apply to the given
205196
* request and to the transfer.
206-
*
207197
* @throws GuzzleException
208198
*/
209199
public function send(RequestInterface $request, array $options = []): ResponseInterface
@@ -213,9 +203,7 @@ public function send(RequestInterface $request, array $options = []): ResponseIn
213203

214204
/**
215205
* @param RequestInterface $request
216-
*
217206
* @return ResponseInterface
218-
*
219207
* @throws \Psr\Http\Client\ClientExceptionInterface
220208
*/
221209
public function sendRequest(RequestInterface $request): ResponseInterface
@@ -225,19 +213,18 @@ public function sendRequest(RequestInterface $request): ResponseInterface
225213

226214
/**
227215
* @param RequestInterface $request Request to send
228-
* @param array $options Request options to apply to the given
216+
* @param array $options Request options to apply to the given
229217
* request and to the transfer.
230218
*/
231219
public function sendAsync(RequestInterface $request, array $options = []): PromiseInterface
232220
{
233-
return $this->guzzleClient->sendAsync($request,$options);
221+
return $this->guzzleClient->sendAsync($request, $options);
234222
}
235223

236224
/**
237-
* @param string $method HTTP method.
238-
* @param string|UriInterface $uri URI object or string.
239-
* @param array $options Request options to apply.
240-
*
225+
* @param string $method HTTP method.
226+
* @param string|UriInterface $uri URI object or string.
227+
* @param array $options Request options to apply.
241228
* @throws GuzzleException
242229
*/
243230
public function request(string $method, $uri, array $options = []): ResponseInterface
@@ -246,9 +233,9 @@ public function request(string $method, $uri, array $options = []): ResponseInte
246233
}
247234

248235
/**
249-
* @param string $method HTTP method
250-
* @param string|UriInterface $uri URI object or string.
251-
* @param array $options Request options to apply.
236+
* @param string $method HTTP method
237+
* @param string|UriInterface $uri URI object or string.
238+
* @param array $options Request options to apply.
252239
*/
253240
public function requestAsync(string $method, $uri, array $options = []): PromiseInterface
254241
{

src/Mailjet/Response.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ class Response
4242

4343
/**
4444
* Construct a Mailjet response.
45-
*
46-
* @param Request $request Mailjet actual request
45+
* @param Request $request Mailjet actual request
4746
* @param ResponseInterface|null $response Guzzle response
4847
*/
4948
public function __construct(Request $request, ?ResponseInterface $response)
@@ -61,7 +60,6 @@ public function __construct(Request $request, ?ResponseInterface $response)
6160
/**
6261
* Status Getter
6362
* return the http status code.
64-
*
6563
* @return int|null status
6664
*/
6765
public function getStatus(): ?int
@@ -81,7 +79,6 @@ public function getBody(): array
8179
/**
8280
* Data Getter
8381
* The data returned by the mailjet call.
84-
*
8582
* @return array data
8683
*/
8784
public function getData(): array
@@ -101,7 +98,6 @@ public function getCount(): ?int
10198
/**
10299
* Error Reason getter
103100
* return the resulting error message.
104-
*
105101
* @return string|null
106102
*/
107103
public function getReasonPhrase(): ?string
@@ -112,7 +108,6 @@ public function getReasonPhrase(): ?string
112108
/**
113109
* Total getter
114110
* return the total count of all results.
115-
*
116111
* @return int|null count
117112
*/
118113
public function getTotal(): ?int
@@ -122,7 +117,6 @@ public function getTotal(): ?int
122117

123118
/**
124119
* Success getter.
125-
*
126120
* @return bool|null true is return code is 2**
127121
*/
128122
public function success(): ?bool
@@ -137,9 +131,7 @@ public function getRequest(): Request
137131

138132
/**
139133
* Decodes a mailjet string response to an object representing that response.
140-
*
141134
* @param string $body The mailjet response as string
142-
*
143135
* @return array Object representing the mailjet response
144136
*/
145137
protected function decodeBody(string $body): array

0 commit comments

Comments
 (0)