ShipmentViewFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A create() 0 11 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Setono\SyliusLagersystemPlugin\Factory;
6
7
use Setono\SyliusLagersystemPlugin\View\ShipmentView;
8
use Sylius\Component\Core\Model\OrderInterface;
9
use Sylius\Component\Core\Model\ShipmentInterface;
10
11
class ShipmentViewFactory implements ShipmentViewFactoryInterface
12
{
13
    /** @var ShippingMethodViewFactoryInterface */
14
    protected $shippingMethodViewFactory;
15
16
    /** @var string */
17
    protected $shipmentViewClass;
18
19
    public function __construct(
20
        ShippingMethodViewFactoryInterface $shippingMethodViewFactory,
21
        string $shipmentViewClass
22
    ) {
23
        $this->shippingMethodViewFactory = $shippingMethodViewFactory;
24
        $this->shipmentViewClass = $shipmentViewClass;
25
    }
26
27
    public function create(ShipmentInterface $shipment, string $locale): ShipmentView
28
    {
29
        /** @var OrderInterface $order */
30
        $order = $shipment->getOrder();
0 ignored issues
show
Unused Code introduced by
The assignment to $order is dead and can be removed.
Loading history...
31
32
        /** @var ShipmentView $shipmentView */
33
        $shipmentView = new $this->shipmentViewClass();
34
        $shipmentView->state = $shipment->getState();
35
        $shipmentView->method = $this->shippingMethodViewFactory->create($shipment, $locale);
36
37
        return $shipmentView;
38
    }
39
}
40