Skip to content

Commit

Permalink
CS Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Wysocki committed Nov 14, 2024
1 parent b62021f commit 4de0b9b
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 28 deletions.
1 change: 1 addition & 0 deletions Controller/Tpay/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public function execute(): ResultInterface
*
* @param string $blikTransactionId
* @param string $blikCode
* @param mixed $blikAlias
*/
protected function blikPay($blikTransactionId, $blikCode, $blikAlias): bool
{
Expand Down
4 changes: 2 additions & 2 deletions Model/Alias.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 1 addition & 6 deletions Model/AliasRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
9 changes: 3 additions & 6 deletions Model/Api/AliasRepositoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion Model/ApiFacade/OpenApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function blikAlias(string $transactionId, string $blikAlias): array
'type' => 0,
'aliases' => [
'value' => $blikAlias,
'type' => 'UID'
'type' => 'UID',
],
],
];
Expand Down
2 changes: 1 addition & 1 deletion Model/ResourceModel/Alias.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class Alias extends AbstractDb
{
protected function _construct(): void
protected function _construct(): void // phpcs:ignore
{
$this->_init('tpay_blik_aliases', 'id');
}
Expand Down
4 changes: 2 additions & 2 deletions Model/ResourceModel/Alias/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 0 additions & 1 deletion Model/TpayConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions Notification/Strategy/BlikAliasNotificationProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}
}
Expand Down
6 changes: 2 additions & 4 deletions Service/TpayAliasService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions Service/TpayAliasServiceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 4de0b9b

Please sign in to comment.