| Total Complexity | 7 |
| Total Lines | 39 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 14 | class CustomerCreatedByAdminRule extends Rule |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * @internal |
||
| 18 | */ |
||
| 19 | public function __construct(private bool $shouldCustomerBeCreatedByAdmin = true) |
||
| 22 | } |
||
| 23 | |||
| 24 | public function getName(): string |
||
| 25 | { |
||
| 26 | return 'customerCreatedByAdmin'; |
||
| 27 | } |
||
| 28 | |||
| 29 | public function match(RuleScope $scope): bool |
||
| 30 | { |
||
| 31 | if (!$scope instanceof CheckoutRuleScope) { |
||
| 32 | return false; |
||
| 33 | } |
||
| 34 | |||
| 35 | if (!$customer = $scope->getSalesChannelContext()->getCustomer()) { |
||
| 36 | return false; |
||
| 37 | } |
||
| 38 | |||
| 39 | return $this->shouldCustomerBeCreatedByAdmin === (bool) $customer->getCreatedById(); |
||
| 40 | } |
||
| 41 | |||
| 42 | public function getConstraints(): array |
||
| 46 | ]; |
||
| 47 | } |
||
| 48 | |||
| 49 | public function getConfig(): RuleConfig |
||
| 53 | } |
||
| 54 | } |
||
| 55 |