diff --git a/makefile b/makefile index 0a3f0ece1..6a68f6598 100644 --- a/makefile +++ b/makefile @@ -78,7 +78,7 @@ phpcheck: ## Starts the PHP syntax checks @find . -name '*.php' -not -path "./vendor/*" -not -path "./tests/*" | xargs -n 1 -P4 php -l phpmin: ## Starts the PHP compatibility checks - @php vendor/bin/phpcs -p --standard=PHPCompatibility --extensions=php --runtime-set testVersion 7.2 ./src + @php vendor/bin/phpcs -p --standard=PHPCompatibility --extensions=php --runtime-set testVersion 7.4 ./src csfix: ## Starts the PHP CS Fixer @PHP_CS_FIXER_IGNORE_ENV=1 php vendor/bin/php-cs-fixer fix --config=./.php_cs.php --dry-run diff --git a/src/Components/CancelManager/CancelItemFacade.php b/src/Components/CancelManager/CancelItemFacade.php index 22e9c22d9..b183b1123 100644 --- a/src/Components/CancelManager/CancelItemFacade.php +++ b/src/Components/CancelManager/CancelItemFacade.php @@ -4,6 +4,7 @@ namespace Kiener\MolliePayments\Components\CancelManager; use Kiener\MolliePayments\Factory\MollieApiFactory; +use Mollie\Api\MollieApiClient; use Psr\Log\LoggerInterface; /** @@ -11,11 +12,10 @@ */ class CancelItemFacade { - /** @var \Mollie\Api\MollieApiClient */ - private $client; + private MollieApiClient $client; - /** @var LoggerInterface */ - private $logger; + + private LoggerInterface $logger; public function __construct(MollieApiFactory $clientFactory, LoggerInterface $logger) { @@ -57,12 +57,10 @@ public function cancelItem(string $orderId, string $mollieLineId, int $quantity, $this->logger->info('Item cancelled successful', ['orderId' => $orderId, 'mollieLineId' => $mollieLineId, 'quantity' => $quantity]); $response = $response->withData($lines); - } catch (\Throwable $e) { $response = $response->failedWithMessage($e->getMessage()); } return $response; } - -} \ No newline at end of file +} diff --git a/src/Components/CancelManager/CancelItemResponse.php b/src/Components/CancelManager/CancelItemResponse.php index 2cdc70c85..cb2736f60 100644 --- a/src/Components/CancelManager/CancelItemResponse.php +++ b/src/Components/CancelManager/CancelItemResponse.php @@ -8,9 +8,12 @@ */ class CancelItemResponse implements \JsonSerializable { - private $message; - private $success = true; + private string $message; + private bool $success = true; + /** + * @var array + */ private array $data = []; public function isSuccessful(): bool @@ -19,14 +22,17 @@ public function isSuccessful(): bool } /** - * @return mixed + * @return string */ - public function getMessage() + public function getMessage(): string { return $this->message; } + /** + * @return false|string + */ public function jsonSerialize(): mixed { return json_encode(['success' => $this->success, 'message' => $this->message]); @@ -40,6 +46,10 @@ public function failedWithMessage(string $message): self return $clone; } + /** + * @param array $data + * @return $this + */ public function withData(array $data): self { $clone = clone $this; @@ -47,9 +57,11 @@ public function withData(array $data): self return $clone; } - public function getData():array + /** + * @return array + */ + public function getData(): array { return $this->data; } - -} \ No newline at end of file +} diff --git a/src/Controller/Api/Order/CancelLineController.php b/src/Controller/Api/Order/CancelLineController.php index cd0d0490e..d30353686 100644 --- a/src/Controller/Api/Order/CancelLineController.php +++ b/src/Controller/Api/Order/CancelLineController.php @@ -15,13 +15,11 @@ class CancelLineController extends AbstractController { - private MollieApiFactory $clientFactory; private CancelItemFacade $cancelItemFacade; public function __construct(MollieApiFactory $clientFactory, CancelItemFacade $cancelItemFacade) { - $this->clientFactory = $clientFactory; $this->cancelItemFacade = $cancelItemFacade; } @@ -67,4 +65,4 @@ public function cancelAction(Request $request, Context $context): Response $result = $this->cancelItemFacade->cancelItem($orderId, $mollieLineId, $quantity, $resetStock); return new JsonResponse($result); } -} \ No newline at end of file +}