Failed Conditions
Push — master ( f11c87...92f16b )
by Łukasz
02:49 queued 02:41
created

AdjustmentViewFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 20
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A create() 0 9 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Sylius\ShopApiPlugin\Factory;
6
7
use Sylius\Component\Order\Model\AdjustmentInterface;
8
use Sylius\ShopApiPlugin\View\AdjustmentView;
9
10
final class AdjustmentViewFactory implements AdjustmentViewFactoryInterface
11
{
12
    /** @var PriceViewFactoryInterface */
13
    private $priceViewFactory;
14
15
    public function __construct(PriceViewFactoryInterface $priceViewFactory)
16
    {
17
        $this->priceViewFactory = $priceViewFactory;
18
    }
19
20
    public function create(AdjustmentInterface $adjustment, int $additionalAmount = 0): AdjustmentView
21
    {
22
        $adjustmentView = new AdjustmentView();
23
24
        $adjustmentView->name = $adjustment->getLabel();
25
        $adjustmentView->amount = $this->priceViewFactory->create($adjustment->getAmount() + $additionalAmount);
26
27
        return $adjustmentView;
28
    }
29
}
30