Passed
Pull Request — master (#1)
by Igor
04:56
created

BrandViewFactory   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 create() 0 9 1
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Setono\SyliusLagersystemPlugin\Factory\Loevgaard;
6
7
use Loevgaard\SyliusBrandPlugin\Model\BrandInterface;
8
use Setono\SyliusLagersystemPlugin\View\Loevgaard\BrandView;
9
10
class BrandViewFactory implements BrandViewFactoryInterface
11
{
12
    /** @var string */
13
    protected $brandViewClass;
14
15
    public function __construct(string $brandViewClass)
16
    {
17
        $this->brandViewClass = $brandViewClass;
18
    }
19
20
    public function create(BrandInterface $brand): BrandView
21
    {
22
        /** @var BrandView $brandView */
23
        $brandView = new $this->brandViewClass();
24
        $brandView->id = $brand->getId();
25
        $brandView->code = $brand->getCode();
26
        $brandView->name = $brand->getName();
27
28
        return $brandView;
29
    }
30
}
31