Completed
Pull Request — master (#188)
by Kamil
03:23
created

ImageViewFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 20
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A create() 0 9 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