Passed
Push — trunk ( 523c9e...1a8c2b )
by Christian
09:38 queued 13s
created

DaysSinceLastOrderRule::getConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace Shopware\Core\Checkout\Customer\Rule;
4
5
use Shopware\Core\Checkout\CheckoutRuleScope;
6
use Shopware\Core\Framework\Rule\Container\DaysSinceRule;
7
use Shopware\Core\Framework\Rule\RuleScope;
8
9
/**
10
 * @package business-ops
11
 */
12
class DaysSinceLastOrderRule extends DaysSinceRule
13
{
14
    public const RULE_NAME = 'customerDaysSinceLastOrder';
15
16
    protected function getDate(RuleScope $scope): ?\DateTimeInterface
17
    {
18
        if (!$customer = $scope->getSalesChannelContext()->getCustomer()) {
19
            return null;
20
        }
21
22
        return $customer->getLastOrderDate();
23
    }
24
25
    protected function supportsScope(RuleScope $scope): bool
26
    {
27
        return $scope instanceof CheckoutRuleScope;
28
    }
29
}
30