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

ImageViewFactory::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 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