Skip to content

Commit

Permalink
chore: fix phpstan error in fixture class
Browse files Browse the repository at this point in the history
  • Loading branch information
delyriand committed Nov 14, 2024
1 parent a4df9a9 commit 4f44b64
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/Fixture/AdvancedPromotionFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace MonsieurBiz\SyliusAdvancedPromotionPlugin\Fixture;

use Doctrine\ORM\EntityManagerInterface;
use InvalidArgumentException;
use MonsieurBiz\SyliusAdvancedPromotionPlugin\Entity\AfterTaxAwareInterface;
use Sylius\Bundle\FixturesBundle\Fixture\AbstractFixture;
use Sylius\Bundle\FixturesBundle\Fixture\FixtureInterface;
Expand All @@ -31,14 +32,25 @@ public function getName(): string
return 'monsieurbiz_advanced_promotion';
}

/**
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function load(array $options): void
{
foreach ($options['promotion_advanced_configuration'] as $data) {
$config = $options['promotion_advanced_configuration'] ?? [];
if (!\is_array($config)) {
throw new InvalidArgumentException('The "promotion_advanced_configuration" option must be an array.');
}
/** @var array $data */
foreach ($config as $data) {
if (!isset($data['code'])) {
continue;
}
$promotion = $this->promotionRepository->findOneBy(['code' => $data['code']]);
if (null === $promotion || !$promotion instanceof AfterTaxAwareInterface) {
continue;
}
$promotion->setAfterTax($data['after_tax']);
$promotion->setAfterTax($data['after_tax'] ?? false);
$this->entityManager->persist($promotion);
}

Expand Down

0 comments on commit 4f44b64

Please sign in to comment.