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

ShipmentViewFactory::__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
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