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

AdjustmentViewFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
dl 0
loc 19
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A create() 0 9 1
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