Completed
Push — master ( 4c3bca...3316d0 )
by Łukasz
11s
created

ImageViewFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A create() 0 8 1
1
<?php
2
3
namespace Sylius\ShopApiPlugin\Factory;
4
5
use Liip\ImagineBundle\Imagine\Cache\CacheManager;
6
use Sylius\Component\Core\Model\ImageInterface;
7
use Sylius\ShopApiPlugin\View\ImageView;
8
9
final class ImageViewFactory implements ImageViewFactoryInterface
10
{
11
    /**
12
     * @var CacheManager
13
     */
14
    private $imagineCacheManager;
15
16
    /**
17
     * @param CacheManager $imagineCacheManager
18
     */
19
    public function __construct(CacheManager $imagineCacheManager)
20
    {
21
        $this->imagineCacheManager = $imagineCacheManager;
22
    }
23
24
    /**
25
     * @param ImageInterface $image
26
     *
27
     * @return ImageView
28
     */
29
    public function create(ImageInterface $image)
30
    {
31
        $imageView = new ImageView();
32
        $imageView->code = $image->getType();
33
        $imageView->url = $this->imagineCacheManager->getBrowserPath($image->getPath(), 'sylius_small');
34
35
        return $imageView;
36
    }
37
}
38