ImageViewFactory::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Sylius\ShopApiPlugin\Factory;
6
7
use Sylius\Component\Core\Model\ImageInterface;
8
use Sylius\ShopApiPlugin\View\ImageView;
9
10
final class ImageViewFactory implements ImageViewFactoryInterface
11
{
12
    /** @var string */
13
    private $imageViewClass;
14
15
    public function __construct(string $imageViewClass)
16
    {
17
        $this->imageViewClass = $imageViewClass;
18
    }
19
20
    public function create(ImageInterface $image): ImageView
21
    {
22
        /** @var ImageView $imageView */
23
        $imageView = new $this->imageViewClass();
24
        $imageView->code = $image->getType();
25
        $imageView->path = $image->getPath();
26
27
        return $imageView;
28
    }
29
}
30