Skip to content

Commit

Permalink
OP-558 - update plugin to Sylius 2 - ecs fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dariusz-rup committed Jan 14, 2025
1 parent 3097fba commit 0b40f18
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<?php

/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* You can find more information about us on https://bitbag.io and write us
* an email on [email protected].
*/

declare(strict_types=1);

namespace BitBag\SyliusBlacklistPlugin\Checker\FraudSuspicion;
Expand All @@ -14,14 +21,15 @@ final class FraudSuspicionActionEligibilityChecker implements FraudSuspicionActi
{
public function __construct(
private FraudSuspicionRepositoryInterface $fraudSuspicionRepository,
private CustomerStateResolverInterface $customerStateResolver
) {}
private CustomerStateResolverInterface $customerStateResolver,
) {
}

public function canAddFraudSuspicion(
OrderInterface $order,
AutomaticBlacklistingConfigurationInterface $automaticBlacklistingConfiguration
AutomaticBlacklistingConfigurationInterface $automaticBlacklistingConfiguration,
): bool {
if ($this->fraudSuspicionRepository->findOneBy(['order' => $order]) !== null) {
if (null !== $this->fraudSuspicionRepository->findOneBy(['order' => $order])) {
return false;
}

Expand All @@ -31,7 +39,7 @@ public function canAddFraudSuspicion(
$lastFraudSuspicionsOfCustomer = $this->fraudSuspicionRepository->countByCustomerAndCommentAndDate(
$customer,
FraudSuspicionInterface::AUTO_GENERATED_STATUS,
$date
$date,
);

if ($lastFraudSuspicionsOfCustomer >= $automaticBlacklistingConfiguration->getPermittedFraudSuspicionsNumber()) {
Expand Down
14 changes: 11 additions & 3 deletions src/Checker/UserRoleChecker.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<?php

/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* You can find more information about us on https://bitbag.io and write us
* an email on [email protected].
*/

declare(strict_types=1);

namespace BitBag\SyliusBlacklistPlugin\Checker;
Expand All @@ -10,13 +17,14 @@
final class UserRoleChecker implements UserRoleCheckerInterface
{
public function __construct(
private TokenStorageInterface $tokenStorage
) {}
private TokenStorageInterface $tokenStorage,
) {
}

public function isAdmin(): bool
{
$token = $this->tokenStorage->getToken();
if ($token === null) {
if (null === $token) {
return false;
}

Expand Down
12 changes: 10 additions & 2 deletions src/EntityListener/FraudSuspicionEntityListener.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<?php

/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* You can find more information about us on https://bitbag.io and write us
* an email on [email protected].
*/

declare(strict_types=1);

namespace BitBag\SyliusBlacklistPlugin\EntityListener;
Expand All @@ -15,8 +22,9 @@ class FraudSuspicionEntityListener
public function __construct(
private SuspiciousOrderResolverInterface $suspiciousOrderResolver,
private CustomerStateResolverInterface $customerStateResolver,
private FraudSuspicionCommonModelConverterInterface $fraudSuspicionCommonModelConverter
) {}
private FraudSuspicionCommonModelConverterInterface $fraudSuspicionCommonModelConverter,
) {
}

public function prePersist(FraudSuspicionInterface $newFraudSuspicion, LifecycleEventArgs $event): void
{
Expand Down
14 changes: 11 additions & 3 deletions src/Factory/FraudSuspicionFactory.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<?php

/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* You can find more information about us on https://bitbag.io and write us
* an email on [email protected].
*/

declare(strict_types=1);

namespace BitBag\SyliusBlacklistPlugin\Factory;
Expand All @@ -11,8 +18,9 @@
final class FraudSuspicionFactory implements FraudSuspicionFactoryInterface
{
public function __construct(
private FactoryInterface $decoratedFactory
) {}
private FactoryInterface $decoratedFactory,
) {
}

public function createNew(): FraudSuspicionInterface
{
Expand Down Expand Up @@ -48,7 +56,7 @@ public function createForAutomaticBlacklistingConfiguration(OrderInterface $orde
$fraudSuspicion->setAddressType(FraudSuspicionInterface::SHIPPING_ADDRESS_TYPE);
$fraudSuspicion->setStatus(FraudSuspicionInterface::AUTO_GENERATED_STATUS);

if ($fraudSuspicion->getCustomerIp() === null) {
if (null === $fraudSuspicion->getCustomerIp()) {
$fraudSuspicion->setCustomerIp($_SERVER['REMOTE_ADDR'] ?? '');
}

Expand Down

0 comments on commit 0b40f18

Please sign in to comment.