Completed
Push — master ( 663845...79fb76 )
by Igor
18s queued 13s
created

AdjustmentViewFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Setono\SyliusLagersystemPlugin\Factory\Order;
6
7
use Setono\SyliusLagersystemPlugin\View\Order\AdjustmentView;
8
use Sylius\Component\Order\Model\AdjustmentInterface;
9
10
class AdjustmentViewFactory implements AdjustmentViewFactoryInterface
11
{
12
    /** @var string */
13
    protected $adjustmentViewClass;
14
15
    public function __construct(string $adjustmentViewClass)
16
    {
17
        $this->adjustmentViewClass = $adjustmentViewClass;
18
    }
19
20
    public function create(AdjustmentInterface $adjustment, int $additionalAmount): AdjustmentView
21
    {
22
        /** @var AdjustmentView $adjustmentView */
23
        $adjustmentView = new $this->adjustmentViewClass();
24
        $adjustmentView->name = $adjustment->getLabel();
25
        $adjustmentView->amount = $adjustment->getAmount() + $additionalAmount;
26
        $adjustmentView->neutral = $adjustment->isNeutral();
27
28
        return $adjustmentView;
29
    }
30
}
31