Total Complexity | 5 |
Total Lines | 29 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | final class RewardHandler implements RewardHandlerInterface |
||
12 | { |
||
13 | private array $handlers; |
||
14 | |||
15 | public function __construct( |
||
19 | } |
||
20 | |||
21 | public function apply(OrderInterface $order): void |
||
22 | { |
||
23 | if (!$order instanceof AffiliateReferralAwareInterface) { |
||
24 | return; |
||
25 | } |
||
26 | |||
27 | if (null === $affiliateReferral = $order->getAffiliateReferral()) { |
||
28 | return; |
||
29 | } |
||
30 | |||
31 | /** @var string $rewardType */ |
||
32 | $rewardType = $affiliateReferral->getRewardType(); |
||
33 | |||
34 | $this->resolve($rewardType)->apply($order); |
||
35 | } |
||
36 | |||
37 | private function resolve(string $rewardType): RewardHandlerInterface |
||
40 | } |
||
41 | } |
||
42 |