Skip to content

Commit

Permalink
cs-fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
JoMessina committed Nov 13, 2023
1 parent 937babb commit c3c9563
Show file tree
Hide file tree
Showing 22 changed files with 45 additions and 81 deletions.
4 changes: 1 addition & 3 deletions src/Client/AccessDeniedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@

namespace Kiboko\Component\Flow\ZohoCRM\Client;

final class AccessDeniedException extends \RuntimeException
{
}
final class AccessDeniedException extends \RuntimeException {}
4 changes: 1 addition & 3 deletions src/Client/ApiRateExceededException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@

namespace Kiboko\Component\Flow\ZohoCRM\Client;

final class ApiRateExceededException extends \RuntimeException
{
}
final class ApiRateExceededException extends \RuntimeException {}
9 changes: 2 additions & 7 deletions src/Client/AuthenticationMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ public function __construct(
private readonly string $clientSecret,
private string $accessToken,
private readonly string $refreshToken,
) {
}
) {}

public function sendRequest(RequestInterface $request): ResponseInterface
{
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/Client/BadRequestException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
5 changes: 2 additions & 3 deletions src/Client/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ public function __construct(
private readonly RequestFactoryInterface $requestFactory,
private readonly UriFactoryInterface $uriFactory,
private readonly StreamFactoryInterface $streamFactory,
) {
}
) {}

/**
* @throws ClientExceptionInterface
Expand Down Expand Up @@ -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

Check failure on line 191 in src/Client/Client.php

View workflow job for this annotation

GitHub Actions / phpstan

Method Kiboko\Component\Flow\ZohoCRM\Client\Client::processResponse() has parameter $body with no value type specified in iterable type array.

Check failure on line 191 in src/Client/Client.php

View workflow job for this annotation

GitHub Actions / phpstan

Method Kiboko\Component\Flow\ZohoCRM\Client\Client::processResponse() has parameter $body with no value type specified in iterable type array.

Check failure on line 191 in src/Client/Client.php

View workflow job for this annotation

GitHub Actions / phpstan

Method Kiboko\Component\Flow\ZohoCRM\Client\Client::processResponse() has parameter $body with no value type specified in iterable type array.
{
if (400 === $response->getStatusCode()) {

Check warning on line 193 in src/Client/Client.php

View workflow job for this annotation

GitHub Actions / infection

Escaped Mutant for Mutator "DecrementInteger": --- Original +++ New @@ @@ } private function processResponse(ResponseInterface $response, null|array $body = []) : void { - if (400 === $response->getStatusCode()) { + if (399 === $response->getStatusCode()) { throw new BadRequestException('The format of the request is not correct. Please check the information sent.', $response); } if (403 === $response->getStatusCode()) {

Check warning on line 193 in src/Client/Client.php

View workflow job for this annotation

GitHub Actions / infection

Escaped Mutant for Mutator "IncrementInteger": --- Original +++ New @@ @@ } private function processResponse(ResponseInterface $response, null|array $body = []) : void { - if (400 === $response->getStatusCode()) { + if (401 === $response->getStatusCode()) { throw new BadRequestException('The format of the request is not correct. Please check the information sent.', $response); } if (403 === $response->getStatusCode()) {
throw new BadRequestException('The format of the request is not correct. Please check the information sent.', $response);
Expand Down
4 changes: 1 addition & 3 deletions src/Client/ForbiddenException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@

namespace Kiboko\Component\Flow\ZohoCRM\Client;

final class ForbiddenException extends \RuntimeException
{
}
final class ForbiddenException extends \RuntimeException {}
4 changes: 1 addition & 3 deletions src/Client/InternalServerErrorException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@

namespace Kiboko\Component\Flow\ZohoCRM\Client;

final class InternalServerErrorException extends \RuntimeException
{
}
final class InternalServerErrorException extends \RuntimeException {}
4 changes: 1 addition & 3 deletions src/Client/InvalidCodeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@

namespace Kiboko\Component\Flow\ZohoCRM\Client;

final class InvalidCodeException extends \RuntimeException
{
}
final class InvalidCodeException extends \RuntimeException {}
8 changes: 4 additions & 4 deletions src/Client/MultiStatusResponseException.php
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -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
);
Expand Down
4 changes: 1 addition & 3 deletions src/Client/NoContentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@

namespace Kiboko\Component\Flow\ZohoCRM\Client;

final class NoContentException extends \RuntimeException
{
}
final class NoContentException extends \RuntimeException {}
4 changes: 1 addition & 3 deletions src/Client/NotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@

namespace Kiboko\Component\Flow\ZohoCRM\Client;

final class NotFoundException extends \RuntimeException
{
}
final class NotFoundException extends \RuntimeException {}
4 changes: 1 addition & 3 deletions src/Client/RequestEntityTooLargeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@

namespace Kiboko\Component\Flow\ZohoCRM\Client;

final class RequestEntityTooLargeException extends \RuntimeException
{
}
final class RequestEntityTooLargeException extends \RuntimeException {}
8 changes: 3 additions & 5 deletions src/Client/SharedAuthenticationMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
}
8 changes: 3 additions & 5 deletions src/ContactLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,19 @@

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) {}

Check failure on line 19 in src/ContactLoader.php

View workflow job for this annotation

GitHub Actions / phpstan

Property Kiboko\Component\Flow\ZohoCRM\ContactLoader::$logger is never read, only written.

Check failure on line 19 in src/ContactLoader.php

View workflow job for this annotation

GitHub Actions / phpstan

Property Kiboko\Component\Flow\ZohoCRM\ContactLoader::$logger is never read, only written.

public function load(): \Generator
{
$line = yield;

Check failure on line 23 in src/ContactLoader.php

View workflow job for this annotation

GitHub Actions / phpstan

Generator expects value type Kiboko\Contract\Bucket\ResultBucketInterface<mixed>, null given.

Check failure on line 23 in src/ContactLoader.php

View workflow job for this annotation

GitHub Actions / phpstan

Generator expects value type Kiboko\Contract\Bucket\ResultBucketInterface<mixed>, null given.
do {
try {
$this->client->upsertContacts($line);
} catch (InternalServerErrorException|ApiRateExceededException $exception) {
} catch (ApiRateExceededException|InternalServerErrorException $exception) {

Check failure on line 27 in src/ContactLoader.php

View workflow job for this annotation

GitHub Actions / phpstan

Dead catch - Kiboko\Component\Flow\ZohoCRM\Client\ApiRateExceededException|Kiboko\Component\Flow\ZohoCRM\Client\InternalServerErrorException is never thrown in the try block.

Check failure on line 27 in src/ContactLoader.php

View workflow job for this annotation

GitHub Actions / phpstan

Dead catch - Kiboko\Component\Flow\ZohoCRM\Client\ApiRateExceededException|Kiboko\Component\Flow\ZohoCRM\Client\InternalServerErrorException is never thrown in the try block.
$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) {

Check failure on line 31 in src/ContactLoader.php

View workflow job for this annotation

GitHub Actions / phpstan

Dead catch - Kiboko\Component\Flow\ZohoCRM\Client\ForbiddenException|Kiboko\Component\Flow\ZohoCRM\Client\NotFoundException|Kiboko\Component\Flow\ZohoCRM\Client\RequestEntityTooLargeException is never thrown in the try block.

Check failure on line 31 in src/ContactLoader.php

View workflow job for this annotation

GitHub Actions / phpstan

Dead catch - Kiboko\Component\Flow\ZohoCRM\Client\ForbiddenException|Kiboko\Component\Flow\ZohoCRM\Client\NotFoundException|Kiboko\Component\Flow\ZohoCRM\Client\RequestEntityTooLargeException is never thrown in the try block.
$this->logger->error($exception->getMessage(), ['exception' => $exception, 'item' => $line]);
yield new \Kiboko\Component\Bucket\RejectionResultBucket($line);
} catch (BadRequestException|MultiStatusResponseException $exception) {

Check failure on line 34 in src/ContactLoader.php

View workflow job for this annotation

GitHub Actions / phpstan

Dead catch - Kiboko\Component\Flow\ZohoCRM\Client\BadRequestException|Kiboko\Component\Flow\ZohoCRM\Client\MultiStatusResponseException is never thrown in the try block.

Check failure on line 34 in src/ContactLoader.php

View workflow job for this annotation

GitHub Actions / phpstan

Dead catch - Kiboko\Component\Flow\ZohoCRM\Client\BadRequestException|Kiboko\Component\Flow\ZohoCRM\Client\MultiStatusResponseException is never thrown in the try block.
Expand Down
7 changes: 3 additions & 4 deletions src/ContactLookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ public function __construct(
private CacheInterface $cache,
private CompiledMapperInterface $mapper,
private string $mappingField,
) {
}
) {}

public function transform(): \Generator
{
Expand All @@ -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;
Expand Down
7 changes: 3 additions & 4 deletions src/DealLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,19 @@
public function __construct(
private Client $client,
private \Psr\Log\LoggerInterface $logger,

Check failure on line 21 in src/DealLoader.php

View workflow job for this annotation

GitHub Actions / phpstan

Property Kiboko\Component\Flow\ZohoCRM\DealLoader::$logger is never read, only written.

Check failure on line 21 in src/DealLoader.php

View workflow job for this annotation

GitHub Actions / phpstan

Property Kiboko\Component\Flow\ZohoCRM\DealLoader::$logger is never read, only written.
) {
}
) {}

public function load(): \Generator
{
$line = yield;

Check failure on line 26 in src/DealLoader.php

View workflow job for this annotation

GitHub Actions / phpstan

Generator expects value type Kiboko\Contract\Bucket\ResultBucketInterface<mixed>, null given.

Check failure on line 26 in src/DealLoader.php

View workflow job for this annotation

GitHub Actions / phpstan

Generator expects value type Kiboko\Contract\Bucket\ResultBucketInterface<mixed>, null given.
do {
try {
$this->client->upsertDeals($line);
} catch (InternalServerErrorException|ApiRateExceededException $exception) {
} catch (ApiRateExceededException|InternalServerErrorException $exception) {

Check failure on line 30 in src/DealLoader.php

View workflow job for this annotation

GitHub Actions / phpstan

Dead catch - Kiboko\Component\Flow\ZohoCRM\Client\ApiRateExceededException|Kiboko\Component\Flow\ZohoCRM\Client\InternalServerErrorException is never thrown in the try block.

Check failure on line 30 in src/DealLoader.php

View workflow job for this annotation

GitHub Actions / phpstan

Dead catch - Kiboko\Component\Flow\ZohoCRM\Client\ApiRateExceededException|Kiboko\Component\Flow\ZohoCRM\Client\InternalServerErrorException is never thrown in the try block.
$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) {

Check failure on line 34 in src/DealLoader.php

View workflow job for this annotation

GitHub Actions / phpstan

Dead catch - Kiboko\Component\Flow\ZohoCRM\Client\ForbiddenException|Kiboko\Component\Flow\ZohoCRM\Client\NotFoundException|Kiboko\Component\Flow\ZohoCRM\Client\RequestEntityTooLargeException is never thrown in the try block.

Check failure on line 34 in src/DealLoader.php

View workflow job for this annotation

GitHub Actions / phpstan

Dead catch - Kiboko\Component\Flow\ZohoCRM\Client\ForbiddenException|Kiboko\Component\Flow\ZohoCRM\Client\NotFoundException|Kiboko\Component\Flow\ZohoCRM\Client\RequestEntityTooLargeException is never thrown in the try block.
$this->logger->error($exception->getMessage(), ['exception' => $exception, 'item' => $line]);
yield new \Kiboko\Component\Bucket\RejectionResultBucket($line);
} catch (BadRequestException|MultiStatusResponseException $exception) {
Expand Down
3 changes: 1 addition & 2 deletions src/DealTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ final class DealTransformer implements TransformerInterface
{
public function __construct(
private string $orderItemsField,
) {
}
) {}

public function transform(): \Generator
{
Expand Down
7 changes: 3 additions & 4 deletions src/GetOrderLookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ public function __construct(
private CompiledMapperInterface $mapper,
private string $subjectMappingField,
private string $storeMappingField,
) {
}
) {}

public function transform(): \Generator
{
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 3 additions & 5 deletions src/OrderLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,19 @@

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
{
$line = yield;
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) {
Expand Down
7 changes: 3 additions & 4 deletions src/OrderLookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ public function __construct(
private CompiledMapperInterface $mapper,
private string $subjectMappingField,
private string $storeMappingField,
) {
}
) {}

public function transform(): \Generator
{
Expand All @@ -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;
Expand Down
8 changes: 3 additions & 5 deletions src/ProductLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,19 @@

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
{
$line = yield;
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) {
Expand Down
7 changes: 3 additions & 4 deletions src/ProductLookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ public function __construct(
private string $mappingField,
private string $orderItemsField,
private string $propertyPath,
) {
}
) {}

public function transform(): \Generator
{
Expand All @@ -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;
Expand Down

0 comments on commit c3c9563

Please sign in to comment.