Completed
Push — master ( 1671b1...4e9462 )
by Kamil
23:39
created

OrderRecalculator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 4
Bugs 2 Features 1
Metric Value
wmc 2
c 4
b 2
f 1
lcom 1
cbo 3
dl 0
loc 44
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A recalculate() 0 6 1
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\Component\Core\OrderProcessing;
13
14
use Sylius\Component\Core\Model\OrderInterface;
15
use Sylius\Component\Core\Taxation\OrderTaxesApplicatorInterface;
16
use Sylius\Component\Promotion\Processor\PromotionProcessorInterface;
17
18
/**
19
 * @author Jan Góralski <[email protected]>
20
 */
21
class OrderRecalculator implements OrderRecalculatorInterface
22
{
23
    /**
24
     * @var PromotionProcessorInterface
25
     */
26
    private $promotionProcessor;
27
28
    /**
29
     * @var OrderTaxesApplicatorInterface
30
     */
31
    private $taxesApplicator;
32
33
    /**
34
     * @var ShippingChargesProcessorInterface
35
     */
36
    private $shippingChargesProcessor;
37
38
    /**
39
     * @param PromotionProcessorInterface $promotionProcessor
40
     * @param OrderTaxesApplicatorInterface $taxesApplicator
41
     * @param ShippingChargesProcessorInterface $shippingChargesProcessor
42
     */
43
    public function __construct(
44
        PromotionProcessorInterface $promotionProcessor,
45
        OrderTaxesApplicatorInterface $taxesApplicator,
46
        ShippingChargesProcessorInterface $shippingChargesProcessor
47
    ) {
48
        $this->promotionProcessor = $promotionProcessor;
49
        $this->taxesApplicator = $taxesApplicator;
50
        $this->shippingChargesProcessor = $shippingChargesProcessor;
51
    }
52
53
    /**
54
     * @param OrderInterface $order
55
     *
56
     * @return OrderInterface
57
     */
58
    public function recalculate(OrderInterface $order)
59
    {
60
        $this->promotionProcessor->process($order);
61
        $this->taxesApplicator->apply($order);
62
        $this->shippingChargesProcessor->applyShippingCharges($order);
63
    }
64
}
65