Skip to content

Commit f68df90

Browse files
committed
chore: codestyle fixup
1 parent fccf045 commit f68df90

25 files changed

Lines changed: 123 additions & 123 deletions

src/Client.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,17 @@ public function __construct(
4949
$errors->addAll($validator->validate(
5050
// @phpstan-ignore-next-line
5151
$options['backoffMaxTries'] ?? null,
52-
[new NotBlank(null, '"backoffMaxTries" option must be provided')]
52+
[new NotBlank(null, '"backoffMaxTries" option must be provided')],
5353
));
5454
$errors->addAll($validator->validate(
5555
// @phpstan-ignore-next-line
5656
$options['backoffMaxTries'] ?? null,
57-
[new Range(['min' => 0, 'max' => 100])]
57+
[new Range(['min' => 0, 'max' => 100])],
5858
));
5959
$errors->addAll($validator->validate(
6060
// @phpstan-ignore-next-line
6161
$options['userAgent'] ?? null,
62-
[new NotBlank(null, '"userAgent" option must be provided')]
62+
[new NotBlank(null, '"userAgent" option must be provided')],
6363
));
6464
if ($errors->count() !== 0) {
6565
$messages = '';
@@ -91,14 +91,14 @@ private function createDefaultDecider(int $maxRetries, LoggerInterface $logger):
9191
$logger->notice(sprintf(
9292
'Got a %s response for this reason: %s, retrying.',
9393
$response->getStatusCode(),
94-
$response->getReasonPhrase()
94+
$response->getReasonPhrase(),
9595
));
9696
return true;
9797
} elseif ($error && $error->getCode() >= 500) {
9898
$logger->notice(sprintf(
9999
'Got a %s error with this message: %s, retrying.',
100100
$error->getCode(),
101-
$error->getMessage()
101+
$error->getMessage(),
102102
));
103103
return true;
104104
} else {
@@ -126,9 +126,9 @@ private function initClient(string $url, ?string $token, array $options): Guzzle
126126
$options['logger'],
127127
new MessageFormatter(
128128
'{hostname} {req_header_User-Agent} - [{ts}] "{method} {resource} {protocol}/{version}"' .
129-
' {code} {res_header_Content-Length}'
129+
' {code} {res_header_Content-Length}',
130130
),
131-
'debug'
131+
'debug',
132132
));
133133
$logger = $options['logger'];
134134
} else {

src/EventsClient.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function __construct(string $notificationApiUrl, string $applicationToken
1919
if (empty($applicationToken)) {
2020
throw new ClientException(sprintf(
2121
'Application token must be non-empty, %s provided.',
22-
json_encode($applicationToken)
22+
json_encode($applicationToken),
2323
));
2424
}
2525
parent::__construct($notificationApiUrl, $applicationToken, $options);
@@ -33,7 +33,7 @@ public function postEvent(Event $requestData): void
3333
'POST',
3434
sprintf('events/%s', $requestData->getEventType()),
3535
['Content-type' => 'application/json'],
36-
$jobDataJson
36+
$jobDataJson,
3737
);
3838
} catch (JsonException $e) {
3939
throw new ClientException('Invalid job data: ' . $e->getMessage(), $e->getCode(), $e);

src/Requests/Subscription.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function jsonSerialize(): array
4444
{
4545
$filters = array_values(array_map(
4646
fn (Filter $v) => $v->jsonSerialize(),
47-
$this->filters
47+
$this->filters,
4848
));
4949
return [
5050
'event' => $this->eventType,
@@ -70,7 +70,7 @@ private function checkEventType(string $eventType): void
7070
throw new ClientException(sprintf(
7171
'Invalid event type "%s", valid types are: "%s".',
7272
$eventType,
73-
implode(', ', $validEventTypes)
73+
implode(', ', $validEventTypes),
7474
));
7575
}
7676
}

src/Responses/Subscription.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function __construct(array $data)
2525
$this->event = $data['event'];
2626
$this->filters = array_values(array_map(
2727
fn(array $item) => new Filter($item),
28-
$data['filters']
28+
$data['filters'],
2929
));
3030
$this->recipientChannel = $data['recipient']['channel'];
3131
$this->recipientAddress = $data['recipient']['address'];

src/SubscriptionClient.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function __construct(string $notificationApiUrl, string $storageApiToken,
2020
if (empty($storageApiToken)) {
2121
throw new ClientException(sprintf(
2222
'Storage API token must be non-empty, %s provided.',
23-
json_encode($storageApiToken)
23+
json_encode($storageApiToken),
2424
));
2525
}
2626
parent::__construct($notificationApiUrl, $storageApiToken, $options);
@@ -34,7 +34,7 @@ public function createSubscription(RequestSubscription $requestData): ResponseSu
3434
'POST',
3535
'project-subscriptions',
3636
['Content-type' => 'application/json'],
37-
$jobDataJson
37+
$jobDataJson,
3838
);
3939
} catch (JsonException $e) {
4040
throw new ClientException('Invalid job data: ' . $e->getMessage(), $e->getCode(), $e);

tests/ClientFactoryTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function testGetClient(): void
4747
new Response(
4848
200,
4949
['Content-Type' => 'application/json'],
50-
self::SAMPLE_RESPONSE_DATA
50+
self::SAMPLE_RESPONSE_DATA,
5151
),
5252
]);
5353
$requestHistory = [];
@@ -58,15 +58,15 @@ public function testGetClient(): void
5858

5959
$clientFactory = new ClientFactory(
6060
'https://dummy',
61-
['handler' => $stack, 'logger' => $logger, 'backoffMaxTries' => 3, 'userAgent' => 'test agent']
61+
['handler' => $stack, 'logger' => $logger, 'backoffMaxTries' => 3, 'userAgent' => 'test agent'],
6262
);
6363
self::assertInstanceOf(
6464
SubscriptionClient::class,
65-
$clientFactory->getSubscriptionClient('dummy', ['backoffMaxTries' => 3, 'userAgent' => 'Test'])
65+
$clientFactory->getSubscriptionClient('dummy', ['backoffMaxTries' => 3, 'userAgent' => 'Test']),
6666
);
6767
self::assertInstanceOf(
6868
EventsClient::class,
69-
$clientFactory->getEventsClient('dummy', ['backoffMaxTries' => 3, 'userAgent' => 'Test'])
69+
$clientFactory->getEventsClient('dummy', ['backoffMaxTries' => 3, 'userAgent' => 'Test']),
7070
);
7171

7272
/** @var Request $request */
@@ -82,7 +82,7 @@ public function testGetClientLazy(): void
8282
new Response(
8383
200,
8484
['Content-Type' => 'application/json'],
85-
self::SAMPLE_RESPONSE_DATA
85+
self::SAMPLE_RESPONSE_DATA,
8686
),
8787
]);
8888
$requestHistory = [];
@@ -93,7 +93,7 @@ public function testGetClientLazy(): void
9393

9494
$clientFactory = new ClientFactory(
9595
'https://dummy',
96-
['handler' => $stack, 'logger' => $logger, 'backoffMaxTries' => 3, 'userAgent' => 'test agent']
96+
['handler' => $stack, 'logger' => $logger, 'backoffMaxTries' => 3, 'userAgent' => 'test agent'],
9797
);
9898
self::assertCount(0, $requestHistory);
9999
$clientFactory->getSubscriptionClient('dummy', ['backoffMaxTries' => 3, 'userAgent' => 'Test']);

tests/ClientTest.php

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ private function getClient(array $options): EventsClient
3434
return new EventsClient(
3535
'https://example.com/',
3636
'testToken',
37-
$options
37+
$options,
3838
);
3939
}
4040

@@ -43,13 +43,13 @@ public function testCreateClientEmptyBackoffAndUserAgent(): void
4343
self::expectException(ClientException::class);
4444
self::expectExceptionMessageMatches(
4545
// phpcs:ignore Generic.Files.LineLength
46-
'#Value "" is invalid: "backoffMaxTries" option must be provided\s*Value "" is invalid: "userAgent" option must be provided#'
46+
'#Value "" is invalid: "backoffMaxTries" option must be provided\s*Value "" is invalid: "userAgent" option must be provided#',
4747
);
4848
new EventsClient(
4949
'http://example.com/',
5050
'testToken',
5151
// @phpstan-ignore-next-line
52-
[]
52+
[],
5353
);
5454
}
5555

@@ -58,41 +58,41 @@ public function testCreateClientInvalidBackoff(): void
5858
self::expectException(ClientException::class);
5959
// phpcs:ignore Generic.Files.LineLength
6060
self::expectExceptionMessage(
61-
'Invalid parameters when creating client: Value "abc" is invalid: This value should be a valid number.'
61+
'Invalid parameters when creating client: Value "abc" is invalid: This value should be a valid number.',
6262
);
6363
new EventsClient(
6464
'http://example.com/',
6565
'testToken',
6666
// @phpstan-ignore-next-line
67-
['backoffMaxTries' => 'abc', 'userAgent' => 'boo']
67+
['backoffMaxTries' => 'abc', 'userAgent' => 'boo'],
6868
);
6969
}
7070

7171
public function testCreateClientTooLowBackoff(): void
7272
{
7373
self::expectException(ClientException::class);
7474
self::expectExceptionMessage(
75-
'Invalid parameters when creating client: Value "-1" is invalid: This value should be between 0 and 100.'
75+
'Invalid parameters when creating client: Value "-1" is invalid: This value should be between 0 and 100.',
7676
);
7777
new EventsClient(
7878
'http://example.com/',
7979
'testToken',
8080
// @phpstan-ignore-next-line
81-
['backoffMaxTries' => -1]
81+
['backoffMaxTries' => -1],
8282
);
8383
}
8484

8585
public function testCreateClientTooHighBackoff(): void
8686
{
8787
self::expectException(ClientException::class);
8888
self::expectExceptionMessage(
89-
'Invalid parameters when creating client: Value "101" is invalid: This value should be between 0 and 100.'
89+
'Invalid parameters when creating client: Value "101" is invalid: This value should be between 0 and 100.',
9090
);
9191
new EventsClient(
9292
'http://example.com/',
9393
'testToken',
9494
// @phpstan-ignore-next-line
95-
['backoffMaxTries' => 101]
95+
['backoffMaxTries' => 101],
9696
);
9797
}
9898

@@ -106,7 +106,7 @@ public function testCreateClientInvalidUrl(): void
106106
[
107107
'backoffMaxTries' => 3,
108108
'userAgent' => 'Test',
109-
]
109+
],
110110
);
111111
}
112112

@@ -126,9 +126,9 @@ private function getPostEventData(): Event
126126
'keboola.orchestrator',
127127
'Orchestrator',
128128
'my-configuration',
129-
'My configuration'
130-
)
131-
)
129+
'My configuration',
130+
),
131+
),
132132
);
133133
}
134134

@@ -138,7 +138,7 @@ public function testClientRequestResponse(): void
138138
new Response(
139139
202,
140140
['Content-Type' => 'application/json'],
141-
null
141+
null,
142142
),
143143
]);
144144
// Add the history middleware to the handler stack.
@@ -174,7 +174,7 @@ public function testLogger(): void
174174
"configRow": null,
175175
"tag": null,
176176
"createdTime": "2021-03-04T21:59:49+00:00"
177-
}'
177+
}',
178178
),
179179
]);
180180
// Add the history middleware to the handler stack.
@@ -189,7 +189,7 @@ public function testLogger(): void
189189
'logger' => $logger,
190190
'backoffMaxTries' => 3,
191191
'userAgent' => 'test agent',
192-
]
192+
],
193193
);
194194
$client->postEvent($this->getPostEventData());
195195
/** @var Request $request */
@@ -205,12 +205,12 @@ public function testRetrySuccess(): void
205205
new Response(
206206
500,
207207
['Content-Type' => 'application/json'],
208-
'{"message" => "Out of order"}'
208+
'{"message" => "Out of order"}',
209209
),
210210
new Response(
211211
501,
212212
['Content-Type' => 'application/json'],
213-
'Out of order'
213+
'Out of order',
214214
),
215215
new Response(
216216
200,
@@ -226,7 +226,7 @@ public function testRetrySuccess(): void
226226
"configRow": null,
227227
"tag": null,
228228
"createdTime": "2021-03-04T21:59:49+00:00"
229-
}'
229+
}',
230230
),
231231
]);
232232
// Add the history middleware to the handler stack.
@@ -241,7 +241,7 @@ public function testRetrySuccess(): void
241241
'backoffMaxTries' => 3,
242242
'userAgent' => 'Test',
243243
'logger' => $logger,
244-
]
244+
],
245245
);
246246
$client->postEvent($this->getPostEventData());
247247
self::assertCount(3, $requestHistory);
@@ -262,7 +262,7 @@ public function testRetryFailure(): void
262262
$responses[] = new Response(
263263
500,
264264
['Content-Type' => 'application/json'],
265-
'{"message" => "Out of order"}'
265+
'{"message" => "Out of order"}',
266266
);
267267
}
268268
$mock = new MockHandler($responses);
@@ -273,7 +273,7 @@ public function testRetryFailure(): void
273273
$stack->push($history);
274274
$logger = new TestLogger();
275275
$client = $this->getClient(
276-
['handler' => $stack, 'backoffMaxTries' => 1, 'userAgent' => 'Test', 'logger' => $logger]
276+
['handler' => $stack, 'backoffMaxTries' => 1, 'userAgent' => 'Test', 'logger' => $logger],
277277
);
278278
try {
279279
$client->postEvent($this->getPostEventData());
@@ -291,7 +291,7 @@ public function testNoRetry(): void
291291
new Response(
292292
401,
293293
['Content-Type' => 'application/json'],
294-
'{"message" => "Unauthorized"}'
294+
'{"message" => "Unauthorized"}',
295295
),
296296
]);
297297
// Add the history middleware to the handler stack.

0 commit comments

Comments
 (0)