From 4de0b9bd78be4e6d071c4f30ea02268415a76f57 Mon Sep 17 00:00:00 2001 From: Adam Wysocki Date: Thu, 14 Nov 2024 11:45:58 +0100 Subject: [PATCH] CS Fixes --- Controller/Tpay/Create.php | 1 + Model/Alias.php | 4 ++-- Model/AliasRepository.php | 7 +------ Model/Api/AliasRepositoryInterface.php | 9 +++------ Model/ApiFacade/OpenApi.php | 2 +- Model/ResourceModel/Alias.php | 2 +- Model/ResourceModel/Alias/Collection.php | 4 ++-- Model/TpayConfigProvider.php | 1 - Notification/Strategy/BlikAliasNotificationProcessor.php | 4 ++-- Service/TpayAliasService.php | 6 ++---- Service/TpayAliasServiceInterface.php | 6 +++--- 11 files changed, 18 insertions(+), 28 deletions(-) diff --git a/Controller/Tpay/Create.php b/Controller/Tpay/Create.php index 609006a..66b7a2e 100644 --- a/Controller/Tpay/Create.php +++ b/Controller/Tpay/Create.php @@ -124,6 +124,7 @@ public function execute(): ResultInterface * * @param string $blikTransactionId * @param string $blikCode + * @param mixed $blikAlias */ protected function blikPay($blikTransactionId, $blikCode, $blikAlias): bool { diff --git a/Model/Alias.php b/Model/Alias.php index 2f0647c..7a8a6de 100644 --- a/Model/Alias.php +++ b/Model/Alias.php @@ -14,8 +14,8 @@ class Alias extends AbstractModel implements AliasInterface public function __construct( Context $context, Registry $registry, - AbstractResource $resource = null, - AbstractDb $resourceCollection = null, + ?AbstractResource $resource = null, + ?AbstractDb $resourceCollection = null, array $data = [] ) { parent::__construct($context, $registry, $resource, $resourceCollection, $data); diff --git a/Model/AliasRepository.php b/Model/AliasRepository.php index aba53e2..0ce7bdc 100644 --- a/Model/AliasRepository.php +++ b/Model/AliasRepository.php @@ -16,6 +16,7 @@ class AliasRepository implements AliasRepositoryInterface /** @var AliasResourceModel */ protected $aliasResourceModel; + /** @phpstan-ignore-next-line */ public function __construct(AliasFactory $aliasFactory, AliasResourceModel $aliasResourceModel) { $this->aliasFactory = $aliasFactory; @@ -30,17 +31,11 @@ public function findByCustomerId(int $customerId): ?AliasInterface return $alias; } - /** - * @inheritDoc - */ public function save(AliasInterface $alias): void { $this->aliasResourceModel->save($alias); } - /** - * @inheritDoc - */ public function remove(AliasInterface $alias): void { $this->aliasResourceModel->delete($alias); diff --git a/Model/Api/AliasRepositoryInterface.php b/Model/Api/AliasRepositoryInterface.php index 4e86c26..4a88103 100644 --- a/Model/Api/AliasRepositoryInterface.php +++ b/Model/Api/AliasRepositoryInterface.php @@ -4,20 +4,17 @@ namespace Tpay\Magento2\Model\Api; +use Exception; use Magento\Framework\Exception\AlreadyExistsException; use Tpay\Magento2\Model\Api\Data\AliasInterface; interface AliasRepositoryInterface { - /** - * @throws AlreadyExistsException - */ + /** @throws AlreadyExistsException */ public function save(AliasInterface $alias): void; public function findByCustomerId(int $customerId): ?AliasInterface; - /** - * @throws \Exception - */ + /** @throws Exception */ public function remove(AliasInterface $alias): void; } diff --git a/Model/ApiFacade/OpenApi.php b/Model/ApiFacade/OpenApi.php index 8830722..a8d9dd4 100755 --- a/Model/ApiFacade/OpenApi.php +++ b/Model/ApiFacade/OpenApi.php @@ -100,7 +100,7 @@ public function blikAlias(string $transactionId, string $blikAlias): array 'type' => 0, 'aliases' => [ 'value' => $blikAlias, - 'type' => 'UID' + 'type' => 'UID', ], ], ]; diff --git a/Model/ResourceModel/Alias.php b/Model/ResourceModel/Alias.php index ada2fbd..8e8c5d2 100644 --- a/Model/ResourceModel/Alias.php +++ b/Model/ResourceModel/Alias.php @@ -6,7 +6,7 @@ class Alias extends AbstractDb { - protected function _construct(): void + protected function _construct(): void // phpcs:ignore { $this->_init('tpay_blik_aliases', 'id'); } diff --git a/Model/ResourceModel/Alias/Collection.php b/Model/ResourceModel/Alias/Collection.php index 92b1a19..b277a9e 100644 --- a/Model/ResourceModel/Alias/Collection.php +++ b/Model/ResourceModel/Alias/Collection.php @@ -3,12 +3,12 @@ namespace Tpay\Magento2\Model\ResourceModel\Alias; use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection; -use Tpay\Magento2\Model\ResourceModel\Alias as AliasResourceModel; use Tpay\Magento2\Model\Alias; +use Tpay\Magento2\Model\ResourceModel\Alias as AliasResourceModel; class Collection extends AbstractCollection { - protected function _construct() + protected function _construct() // phpcs:ignore { $this->_init(Alias::class, AliasResourceModel::class); } diff --git a/Model/TpayConfigProvider.php b/Model/TpayConfigProvider.php index 9e3ba1e..52cdcb4 100644 --- a/Model/TpayConfigProvider.php +++ b/Model/TpayConfigProvider.php @@ -10,7 +10,6 @@ use Magento\Payment\Helper\Data as PaymentHelper; use Tpay\Magento2\Api\TpayConfigInterface; use Tpay\Magento2\Api\TpayInterface; -use Tpay\Magento2\Model\Api\AliasRepositoryInterface; use Tpay\Magento2\Model\ApiFacade\TpayConfig\ConfigFacade; use Tpay\Magento2\Model\ApiFacade\Transaction\TransactionApiFacade; use Tpay\Magento2\Service\TpayAliasServiceInterface; diff --git a/Notification/Strategy/BlikAliasNotificationProcessor.php b/Notification/Strategy/BlikAliasNotificationProcessor.php index 822d96c..f0bb9b0 100644 --- a/Notification/Strategy/BlikAliasNotificationProcessor.php +++ b/Notification/Strategy/BlikAliasNotificationProcessor.php @@ -21,11 +21,11 @@ public function process(?int $storeId) $response = $_POST; $userId = (int) explode('_', $response['value'])[1]; - if ($response['event'] === 'ALIAS_REGISTER') { + if ('ALIAS_REGISTER' === $response['event']) { $this->aliasService->saveCustomerAlias($userId, $response['value']); } - if ($response['event'] === 'ALIAS_UNREGISTER') { + if ('ALIAS_UNREGISTER' === $response['event']) { $this->aliasService->removeCustomerAlias($userId, $response['value']); } } diff --git a/Service/TpayAliasService.php b/Service/TpayAliasService.php index d45cd33..5ad8e0c 100644 --- a/Service/TpayAliasService.php +++ b/Service/TpayAliasService.php @@ -4,6 +4,7 @@ namespace Tpay\Magento2\Service; +use Exception; use Magento\Framework\App\ResourceConnection; use Tpay\Magento2\Model\Api\AliasRepositoryInterface; use Tpay\Magento2\Model\ResourceModel\Alias\Collection; @@ -54,15 +55,12 @@ public function saveCustomerAlias(int $customerId, string $alias): void } } - /** - * @inheritDoc - */ public function removeCustomerAlias(int $customerId, string $alias): void { $aliasEntity = $this->aliasRepository->findByCustomerId($customerId); if (!$aliasEntity->getId()) { - throw new \Exception("Alias for customerId {$customerId} not found"); + throw new Exception("Alias for customerId {$customerId} not found"); } $this->aliasRepository->remove($aliasEntity); diff --git a/Service/TpayAliasServiceInterface.php b/Service/TpayAliasServiceInterface.php index e0680df..74c6626 100644 --- a/Service/TpayAliasServiceInterface.php +++ b/Service/TpayAliasServiceInterface.php @@ -4,14 +4,14 @@ namespace Tpay\Magento2\Service; +use Exception; + interface TpayAliasServiceInterface { public function getCustomerAlias(int $customerId); public function saveCustomerAlias(int $customerId, string $alias): void; - /** - * @throws \Exception - */ + /** @throws Exception */ public function removeCustomerAlias(int $customerId, string $alias): void; }