From c3c9563c715dfaa3e53d54b018e53bf450fbd21d Mon Sep 17 00:00:00 2001 From: Jonathan Date: Mon, 13 Nov 2023 17:28:03 +0100 Subject: [PATCH] cs-fixer --- src/Client/AccessDeniedException.php | 4 +--- src/Client/ApiRateExceededException.php | 4 +--- src/Client/AuthenticationMiddleware.php | 9 ++------- src/Client/BadRequestException.php | 2 +- src/Client/Client.php | 5 ++--- src/Client/ForbiddenException.php | 4 +--- src/Client/InternalServerErrorException.php | 4 +--- src/Client/InvalidCodeException.php | 4 +--- src/Client/MultiStatusResponseException.php | 8 ++++---- src/Client/NoContentException.php | 4 +--- src/Client/NotFoundException.php | 4 +--- src/Client/RequestEntityTooLargeException.php | 4 +--- src/Client/SharedAuthenticationMiddleware.php | 8 +++----- src/ContactLoader.php | 8 +++----- src/ContactLookup.php | 7 +++---- src/DealLoader.php | 7 +++---- src/DealTransformer.php | 3 +-- src/GetOrderLookup.php | 7 +++---- src/OrderLoader.php | 8 +++----- src/OrderLookup.php | 7 +++---- src/ProductLoader.php | 8 +++----- src/ProductLookup.php | 7 +++---- 22 files changed, 45 insertions(+), 81 deletions(-) diff --git a/src/Client/AccessDeniedException.php b/src/Client/AccessDeniedException.php index af44139..1b306d7 100644 --- a/src/Client/AccessDeniedException.php +++ b/src/Client/AccessDeniedException.php @@ -4,6 +4,4 @@ namespace Kiboko\Component\Flow\ZohoCRM\Client; -final class AccessDeniedException extends \RuntimeException -{ -} +final class AccessDeniedException extends \RuntimeException {} diff --git a/src/Client/ApiRateExceededException.php b/src/Client/ApiRateExceededException.php index d0ec5cd..fcc342e 100644 --- a/src/Client/ApiRateExceededException.php +++ b/src/Client/ApiRateExceededException.php @@ -4,6 +4,4 @@ namespace Kiboko\Component\Flow\ZohoCRM\Client; -final class ApiRateExceededException extends \RuntimeException -{ -} +final class ApiRateExceededException extends \RuntimeException {} diff --git a/src/Client/AuthenticationMiddleware.php b/src/Client/AuthenticationMiddleware.php index 536cf4c..ea18dbf 100644 --- a/src/Client/AuthenticationMiddleware.php +++ b/src/Client/AuthenticationMiddleware.php @@ -21,8 +21,7 @@ public function __construct( private readonly string $clientSecret, private string $accessToken, private readonly string $refreshToken, - ) { - } + ) {} public function sendRequest(RequestInterface $request): ResponseInterface { @@ -62,11 +61,7 @@ private function refreshToken(): void ); if (200 !== $response->getStatusCode()) { - throw new AccessDeniedException(sprintf( - 'Something went wrong while refreshing your credentials: %d - "%s"', - $response->getStatusCode(), - $response->getBody()->getContents(), - )); + throw new AccessDeniedException(sprintf('Something went wrong while refreshing your credentials: %d - "%s"', $response->getStatusCode(), $response->getBody()->getContents())); } $credentials = json_decode($response->getBody()->getContents(), true, 512, \JSON_THROW_ON_ERROR); diff --git a/src/Client/BadRequestException.php b/src/Client/BadRequestException.php index e8eecce..8810bc1 100644 --- a/src/Client/BadRequestException.php +++ b/src/Client/BadRequestException.php @@ -8,7 +8,7 @@ final class BadRequestException extends \RuntimeException { - public function __construct(string $message, private readonly ResponseInterface $response, int $code = 0, \Throwable|null $previous = null) + public function __construct(string $message, private readonly ResponseInterface $response, int $code = 0, \Throwable $previous = null) { parent::__construct($message, $code, $previous); } diff --git a/src/Client/Client.php b/src/Client/Client.php index 8f13b28..e490437 100644 --- a/src/Client/Client.php +++ b/src/Client/Client.php @@ -19,8 +19,7 @@ public function __construct( private readonly RequestFactoryInterface $requestFactory, private readonly UriFactoryInterface $uriFactory, private readonly StreamFactoryInterface $streamFactory, - ) { - } + ) {} /** * @throws ClientExceptionInterface @@ -189,7 +188,7 @@ public function searchOrder(string $subject, string $store): array return $result['data'][0]; } - private function processResponse(ResponseInterface $response, array|null $body = []): void + private function processResponse(ResponseInterface $response, null|array $body = []): void { if (400 === $response->getStatusCode()) { throw new BadRequestException('The format of the request is not correct. Please check the information sent.', $response); diff --git a/src/Client/ForbiddenException.php b/src/Client/ForbiddenException.php index 1e88e7b..1e1e351 100644 --- a/src/Client/ForbiddenException.php +++ b/src/Client/ForbiddenException.php @@ -4,6 +4,4 @@ namespace Kiboko\Component\Flow\ZohoCRM\Client; -final class ForbiddenException extends \RuntimeException -{ -} +final class ForbiddenException extends \RuntimeException {} diff --git a/src/Client/InternalServerErrorException.php b/src/Client/InternalServerErrorException.php index 39cf59d..6d4fc4b 100644 --- a/src/Client/InternalServerErrorException.php +++ b/src/Client/InternalServerErrorException.php @@ -4,6 +4,4 @@ namespace Kiboko\Component\Flow\ZohoCRM\Client; -final class InternalServerErrorException extends \RuntimeException -{ -} +final class InternalServerErrorException extends \RuntimeException {} diff --git a/src/Client/InvalidCodeException.php b/src/Client/InvalidCodeException.php index 7cf769d..c7a8965 100644 --- a/src/Client/InvalidCodeException.php +++ b/src/Client/InvalidCodeException.php @@ -4,6 +4,4 @@ namespace Kiboko\Component\Flow\ZohoCRM\Client; -final class InvalidCodeException extends \RuntimeException -{ -} +final class InvalidCodeException extends \RuntimeException {} diff --git a/src/Client/MultiStatusResponseException.php b/src/Client/MultiStatusResponseException.php index 473a161..4657458 100644 --- a/src/Client/MultiStatusResponseException.php +++ b/src/Client/MultiStatusResponseException.php @@ -8,13 +8,13 @@ final class MultiStatusResponseException extends \RuntimeException { - public function __construct(private readonly ResponseInterface $response, array|null $body = [], int $code = 0, \Throwable|null $previous = null) + public function __construct(private readonly ResponseInterface $response, null|array $body = [], int $code = 0, \Throwable $previous = null) { - $contents = json_decode($response->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR); + $contents = json_decode($response->getBody()->getContents(), true, 512, \JSON_THROW_ON_ERROR); $messages = []; foreach ($contents['data'] as $key => $item) { - if ($item['code'] !== 'SUCCESS') { + if ('SUCCESS' !== $item['code']) { $messages[] = [ 'response' => $item, 'body' => $body[$key], @@ -23,7 +23,7 @@ public function __construct(private readonly ResponseInterface $response, array| } parent::__construct( - sprintf('Zoho\'s response contains multiple statuses, %d items in the batch may have failed: %s', count($messages), json_encode($messages, JSON_THROW_ON_ERROR)), + sprintf('Zoho\'s response contains multiple statuses, %d items in the batch may have failed: %s', \count($messages), json_encode($messages, \JSON_THROW_ON_ERROR)), $code, $previous ); diff --git a/src/Client/NoContentException.php b/src/Client/NoContentException.php index 1ace126..408c811 100644 --- a/src/Client/NoContentException.php +++ b/src/Client/NoContentException.php @@ -4,6 +4,4 @@ namespace Kiboko\Component\Flow\ZohoCRM\Client; -final class NoContentException extends \RuntimeException -{ -} +final class NoContentException extends \RuntimeException {} diff --git a/src/Client/NotFoundException.php b/src/Client/NotFoundException.php index f145fcd..d3fb2e9 100644 --- a/src/Client/NotFoundException.php +++ b/src/Client/NotFoundException.php @@ -4,6 +4,4 @@ namespace Kiboko\Component\Flow\ZohoCRM\Client; -final class NotFoundException extends \RuntimeException -{ -} +final class NotFoundException extends \RuntimeException {} diff --git a/src/Client/RequestEntityTooLargeException.php b/src/Client/RequestEntityTooLargeException.php index 8aeeaba..66c575e 100644 --- a/src/Client/RequestEntityTooLargeException.php +++ b/src/Client/RequestEntityTooLargeException.php @@ -4,6 +4,4 @@ namespace Kiboko\Component\Flow\ZohoCRM\Client; -final class RequestEntityTooLargeException extends \RuntimeException -{ -} +final class RequestEntityTooLargeException extends \RuntimeException {} diff --git a/src/Client/SharedAuthenticationMiddleware.php b/src/Client/SharedAuthenticationMiddleware.php index ba0ef35..37f9e5c 100644 --- a/src/Client/SharedAuthenticationMiddleware.php +++ b/src/Client/SharedAuthenticationMiddleware.php @@ -6,8 +6,6 @@ use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestFactoryInterface; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\UriFactoryInterface; class SharedAuthenticationMiddleware @@ -23,11 +21,11 @@ public static function getInstance( string $clientSecret, string $accessToken, string $refreshToken, - ): AuthenticationMiddleware - { - if (self::$instance === null) { + ): AuthenticationMiddleware { + if (null === self::$instance) { self::$instance = new AuthenticationMiddleware($decorated, $requestFactory, $uriFactory, $oauthBaseUri, $clientId, $clientSecret, $accessToken, $refreshToken); } + return self::$instance; } } diff --git a/src/ContactLoader.php b/src/ContactLoader.php index f90eb2e..561b3a2 100644 --- a/src/ContactLoader.php +++ b/src/ContactLoader.php @@ -16,9 +16,7 @@ final readonly class ContactLoader implements LoaderInterface { - public function __construct(private Client $client, private \Psr\Log\LoggerInterface $logger) - { - } + public function __construct(private Client $client, private \Psr\Log\LoggerInterface $logger) {} public function load(): \Generator { @@ -26,11 +24,11 @@ public function load(): \Generator do { try { $this->client->upsertContacts($line); - } catch (InternalServerErrorException|ApiRateExceededException $exception) { + } catch (ApiRateExceededException|InternalServerErrorException $exception) { $this->logger->critical($exception->getMessage(), ['exception' => $exception, 'item' => $line]); yield new \Kiboko\Component\Bucket\RejectionResultBucket($line); - } catch (ForbiddenException|RequestEntityTooLargeException|NotFoundException $exception) { + } catch (ForbiddenException|NotFoundException|RequestEntityTooLargeException $exception) { $this->logger->error($exception->getMessage(), ['exception' => $exception, 'item' => $line]); yield new \Kiboko\Component\Bucket\RejectionResultBucket($line); } catch (BadRequestException|MultiStatusResponseException $exception) { diff --git a/src/ContactLookup.php b/src/ContactLookup.php index e8f8579..bc1dcb3 100644 --- a/src/ContactLookup.php +++ b/src/ContactLookup.php @@ -26,8 +26,7 @@ public function __construct( private CacheInterface $cache, private CompiledMapperInterface $mapper, private string $mappingField, - ) { - } + ) {} public function transform(): \Generator { @@ -42,12 +41,12 @@ public function transform(): \Generator $this->cache->set($encodedEmail, $lookup); } - } catch (InternalServerErrorException|ApiRateExceededException $exception) { + } catch (ApiRateExceededException|InternalServerErrorException $exception) { $this->logger->critical($exception->getMessage(), ['exception' => $exception, 'item' => $line]); $line = yield new RejectionResultBucket($line); return; - } catch (BadRequestException|ForbiddenException|RequestEntityTooLargeException|NotFoundException|NoContentException $exception) { + } catch (BadRequestException|ForbiddenException|NoContentException|NotFoundException|RequestEntityTooLargeException $exception) { $this->logger->error($exception->getMessage(), ['exception' => $exception, 'item' => $line]); $line = yield new RejectionResultBucket($line); continue; diff --git a/src/DealLoader.php b/src/DealLoader.php index 0254e50..44642d9 100644 --- a/src/DealLoader.php +++ b/src/DealLoader.php @@ -19,8 +19,7 @@ public function __construct( private Client $client, private \Psr\Log\LoggerInterface $logger, - ) { - } + ) {} public function load(): \Generator { @@ -28,11 +27,11 @@ public function load(): \Generator do { try { $this->client->upsertDeals($line); - } catch (InternalServerErrorException|ApiRateExceededException $exception) { + } catch (ApiRateExceededException|InternalServerErrorException $exception) { $this->logger->critical($exception->getMessage(), ['exception' => $exception, 'item' => $line]); yield new \Kiboko\Component\Bucket\RejectionResultBucket($line); - } catch (ForbiddenException|RequestEntityTooLargeException|NotFoundException $exception) { + } catch (ForbiddenException|NotFoundException|RequestEntityTooLargeException $exception) { $this->logger->error($exception->getMessage(), ['exception' => $exception, 'item' => $line]); yield new \Kiboko\Component\Bucket\RejectionResultBucket($line); } catch (BadRequestException|MultiStatusResponseException $exception) { diff --git a/src/DealTransformer.php b/src/DealTransformer.php index 05d4a3f..f31483e 100644 --- a/src/DealTransformer.php +++ b/src/DealTransformer.php @@ -11,8 +11,7 @@ final class DealTransformer implements TransformerInterface { public function __construct( private string $orderItemsField, - ) { - } + ) {} public function transform(): \Generator { diff --git a/src/GetOrderLookup.php b/src/GetOrderLookup.php index e397312..4d1920f 100644 --- a/src/GetOrderLookup.php +++ b/src/GetOrderLookup.php @@ -27,8 +27,7 @@ public function __construct( private CompiledMapperInterface $mapper, private string $subjectMappingField, private string $storeMappingField, - ) { - } + ) {} public function transform(): \Generator { @@ -57,12 +56,12 @@ public function transform(): \Generator $line = yield new AcceptanceResultBucket($output); } catch (NoContentException) { $line = yield new AcceptanceResultBucket($line); - } catch (InternalServerErrorException|ApiRateExceededException $exception) { + } catch (ApiRateExceededException|InternalServerErrorException $exception) { $this->logger->critical($exception->getMessage(), ['exception' => $exception, 'item' => $line]); $line = yield new RejectionResultBucket($line); return; - } catch (BadRequestException|ForbiddenException|RequestEntityTooLargeException|NotFoundException $exception) { + } catch (BadRequestException|ForbiddenException|NotFoundException|RequestEntityTooLargeException $exception) { $this->logger->error($exception->getMessage(), ['exception' => $exception, 'item' => $line]); $line = yield new RejectionResultBucket($line); continue; diff --git a/src/OrderLoader.php b/src/OrderLoader.php index 63b475c..64eba0c 100644 --- a/src/OrderLoader.php +++ b/src/OrderLoader.php @@ -16,9 +16,7 @@ final readonly class OrderLoader implements LoaderInterface { - public function __construct(private Client $client, private \Psr\Log\LoggerInterface $logger) - { - } + public function __construct(private Client $client, private \Psr\Log\LoggerInterface $logger) {} public function load(): \Generator { @@ -26,11 +24,11 @@ public function load(): \Generator do { try { $this->client->upsertOrders($line); - } catch (InternalServerErrorException|ApiRateExceededException $exception) { + } catch (ApiRateExceededException|InternalServerErrorException $exception) { $this->logger->critical($exception->getMessage(), ['exception' => $exception, 'item' => $line]); yield new \Kiboko\Component\Bucket\RejectionResultBucket($line); - } catch (ForbiddenException|RequestEntityTooLargeException|NotFoundException $exception) { + } catch (ForbiddenException|NotFoundException|RequestEntityTooLargeException $exception) { $this->logger->error($exception->getMessage(), ['exception' => $exception, 'item' => $line]); yield new \Kiboko\Component\Bucket\RejectionResultBucket($line); } catch (BadRequestException|MultiStatusResponseException $exception) { diff --git a/src/OrderLookup.php b/src/OrderLookup.php index c723603..6391051 100644 --- a/src/OrderLookup.php +++ b/src/OrderLookup.php @@ -27,8 +27,7 @@ public function __construct( private CompiledMapperInterface $mapper, private string $subjectMappingField, private string $storeMappingField, - ) { - } + ) {} public function transform(): \Generator { @@ -43,12 +42,12 @@ public function transform(): \Generator $this->cache->set($encodingKey, $lookup); } - } catch (InternalServerErrorException|ApiRateExceededException $exception) { + } catch (ApiRateExceededException|InternalServerErrorException $exception) { $this->logger->critical($exception->getMessage(), ['exception' => $exception, 'item' => $line]); $line = yield new RejectionResultBucket($line); return; - } catch (BadRequestException|ForbiddenException|RequestEntityTooLargeException|NotFoundException|NoContentException $exception) { + } catch (BadRequestException|ForbiddenException|NoContentException|NotFoundException|RequestEntityTooLargeException $exception) { $this->logger->error($exception->getMessage(), ['exception' => $exception, 'item' => $line]); $line = yield new RejectionResultBucket($line); continue; diff --git a/src/ProductLoader.php b/src/ProductLoader.php index 3f9f95f..fdb2433 100644 --- a/src/ProductLoader.php +++ b/src/ProductLoader.php @@ -16,9 +16,7 @@ final readonly class ProductLoader implements LoaderInterface { - public function __construct(private Client $client, private \Psr\Log\LoggerInterface $logger) - { - } + public function __construct(private Client $client, private \Psr\Log\LoggerInterface $logger) {} public function load(): \Generator { @@ -26,11 +24,11 @@ public function load(): \Generator do { try { $this->client->upsertProducts($line); - } catch (InternalServerErrorException|ApiRateExceededException $exception) { + } catch (ApiRateExceededException|InternalServerErrorException $exception) { $this->logger->critical($exception->getMessage(), ['exception' => $exception, 'item' => $line]); yield new \Kiboko\Component\Bucket\RejectionResultBucket($line); - } catch (ForbiddenException|RequestEntityTooLargeException|NotFoundException $exception) { + } catch (ForbiddenException|NotFoundException|RequestEntityTooLargeException $exception) { $this->logger->error($exception->getMessage(), ['exception' => $exception, 'item' => $line]); yield new \Kiboko\Component\Bucket\RejectionResultBucket($line); } catch (BadRequestException|MultiStatusResponseException $exception) { diff --git a/src/ProductLookup.php b/src/ProductLookup.php index 36e0ec1..8ebb08f 100644 --- a/src/ProductLookup.php +++ b/src/ProductLookup.php @@ -28,8 +28,7 @@ public function __construct( private string $mappingField, private string $orderItemsField, private string $propertyPath, - ) { - } + ) {} public function transform(): \Generator { @@ -46,12 +45,12 @@ public function transform(): \Generator $this->cache->set(sprintf('product.%s', $item[$this->mappingField]), $lookup); } - } catch (InternalServerErrorException|ApiRateExceededException $exception) { + } catch (ApiRateExceededException|InternalServerErrorException $exception) { $this->logger->critical($exception->getMessage(), ['exception' => $exception, 'item' => $line]); $line = yield new RejectionResultBucket($line); return; - } catch (BadRequestException|ForbiddenException|RequestEntityTooLargeException|NotFoundException|NoContentException $exception) { + } catch (BadRequestException|ForbiddenException|NoContentException|NotFoundException|RequestEntityTooLargeException $exception) { $this->logger->error($exception->getMessage(), ['exception' => $exception, 'item' => $line]); $line = yield new RejectionResultBucket($line); continue 2;