Skip to content

Commit

Permalink
Merge pull request #2680 from coreshop/coding-standard/refactor-4.0
Browse files Browse the repository at this point in the history
[CS] Refactor
  • Loading branch information
dpfaffenbauer authored Aug 12, 2024
2 parents f4766cb + c43e3ae commit f26277d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ class IndexActionSettingsSubscriber implements EventSubscriberInterface
{
public function __construct(
private int $decimalPrecision,
private int $decimalFactor
)
{
private int $decimalFactor,
) {
}

public static function getSubscribedEvents()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function getPrice($subject, array $context, array $configuration): int
if (isset($context['unitDefinition']) && $context['unitDefinition'] instanceof ProductUnitDefinitionInterface) {
throw new NoRetailPriceFoundException(__CLASS__);
}

Assert::keyExists($context, 'base_currency');
Assert::isInstanceOf($context['base_currency'], CurrencyInterface::class);

Expand Down
10 changes: 4 additions & 6 deletions src/CoreShop/Component/Variant/AttributeCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@

class AttributeCollector implements AttributeCollectorInterface
{

public function __construct(private EventDispatcherInterface $eventDispatcher)
{
public function __construct(
private EventDispatcherInterface $eventDispatcher,
) {
}

/**
Expand All @@ -57,10 +57,9 @@ public function getAttributes(array $products, bool $showInList = false): array
{
$resolvedGroups = [];
foreach ($products as $product) {

$event = $this->eventDispatcher->dispatch(new VariantAvailabilityEvent($product), 'coreshop.attribute.collector.preCondition');

if (!$event->isConditionMet()){
if (!$event->isConditionMet()) {
continue;
}

Expand All @@ -86,7 +85,6 @@ public function getAttributes(array $products, bool $showInList = false): array
$group->setGroup($attributeGroup);
$group->setType(get_class($attribute));


$resolvedGroups[$attributeGroup->getId()] = $group;
} else {
$group = $resolvedGroups[$attributeGroup->getId()];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ class VariantAvailabilityEvent extends Event
{
private bool $conditionMet = true;

public function __construct(private ProductVariantAwareInterface $product)
{
public function __construct(
private ProductVariantAwareInterface $product,
) {
}

public function getProduct(): ProductVariantAwareInterface
Expand All @@ -43,4 +44,4 @@ public function isConditionMet(): bool
{
return $this->conditionMet;
}
}
}

0 comments on commit f26277d

Please sign in to comment.