Completed
Push — master ( 230277...71b70e )
by Kamil
18:48
created

PromotionProcessor::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 4
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sylius\Bundle\CoreBundle\OrderProcessing;
13
14
use Sylius\Component\Core\Model\OrderInterface;
15
use Sylius\Component\Promotion\Model\PromotionSubjectInterface;
16
use Sylius\Component\Promotion\Processor\PromotionProcessor as BasePromotionProcessor;
17
use Sylius\Component\Resource\Exception\UnexpectedTypeException;
18
19
/**
20
 * @author Kristian Loevstroem <[email protected]>
21
 */
22
class PromotionProcessor extends BasePromotionProcessor
23
{
24
    /**
25
     * @param PromotionSubjectInterface $subject
26
     *
27
     * @return array
28
     */
29
    protected function getActivePromotions(PromotionSubjectInterface $subject)
30
    {
31
        if (!$subject instanceof OrderInterface) {
32
            throw new UnexpectedTypeException($subject, OrderInterface::class);
33
        }
34
35
        if (null === $this->promotions) {
36
            $channel = $subject->getChannel();
37
            $this->promotions = $this->repository->findActiveByChannel($channel);
38
        }
39
40
        return $this->promotions;
41
    }
42
}
43