Failed Conditions
Pull Request — master (#188)
by Kamil
04:26
created

ImageViewFactory::__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
namespace Sylius\ShopApiPlugin\Factory;
4
5
use Sylius\Component\Core\Model\ImageInterface;
6
use Sylius\ShopApiPlugin\View\ImageView;
7
8
final class ImageViewFactory implements ImageViewFactoryInterface
9
{
10
    /** @var string */
11
    private $imageViewClass;
12
13
    public function __construct(string $imageViewClass)
14
    {
15
        $this->imageViewClass = $imageViewClass;
16
    }
17
18
    public function create(ImageInterface $image): ImageView
19
    {
20
        /** @var ImageView $imageView */
21
        $imageView = new $this->imageViewClass();
22
        $imageView->code = $image->getType();
23
        $imageView->path = $image->getPath();
24
25
        return $imageView;
26
    }
27
}
28