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

BrandViewFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
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