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

AdjustmentViewFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 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