Completed
Push — master ( 41948a...5bb6bb )
by Łukasz
17:08 queued 13:33
created

ShipmentViewFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 28
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
4
5
namespace Sylius\ShopApiPlugin\Factory;
6
7
use Sylius\Component\Core\Model\ShipmentInterface;
8
use Sylius\ShopApiPlugin\View\ShipmentView;
9
10
final class ShipmentViewFactory implements ShipmentViewFactoryInterface
11
{
12
    /**
13
     * @var ShippingMethodViewFactoryInterface
14
     */
15
    private $shippingMethodViewFactory;
16
17
    /**
18
     * @param ShippingMethodViewFactoryInterface $shippingMethodViewFactory
19
     */
20
    public function __construct(ShippingMethodViewFactoryInterface $shippingMethodViewFactory)
21
    {
22
        $this->shippingMethodViewFactory = $shippingMethodViewFactory;
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function create(ShipmentInterface $shipment, $locale)
29
    {
30
        $shipmentView = new ShipmentView();
31
32
        $shipmentView->state = $shipment->getState();
33
        $shipmentView->method = $this->shippingMethodViewFactory->create($shipment, $locale);
34
35
        return $shipmentView;
36
    }
37
}
38