Completed
Push — master ( 3e0b85...9d0d49 )
by André
63:27 queued 41:30
created

ResolverFactory   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 3
A createCacheResolver() 0 4 1
1
<?php
2
3
/**
4
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
5
 * @license For full copyright and license information view LICENSE file distributed with this source code.
6
 */
7
namespace eZ\Bundle\EzPublishCoreBundle\Imagine;
8
9
use eZ\Publish\Core\MVC\ConfigResolverInterface;
10
use Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface;
11
12
class ResolverFactory
13
{
14
    /**
15
     * @var \Liip\ImagineBundle\Imagine\Cache\Resolver\ResolverInterface
16
     */
17
    private $resolver;
18
19
    /**
20
     * @var string
21
     */
22
    private $proxyResolverClass;
23
24
    /**
25
     * @var array
26
     */
27
    private $hosts = [];
28
29
    public function __construct(ConfigResolverInterface $configResolver, ResolverInterface $resolver, $proxyResolverClass)
30
    {
31
        $this->resolver = $resolver;
32
        $this->proxyResolverClass = $proxyResolverClass;
33
34
        if ($configResolver->hasParameter('image_host') &&
35
            ($imageHost = $configResolver->getParameter('image_host')) !== '') {
36
            $this->hosts = [$imageHost];
37
        }
38
    }
39
40
    public function createCacheResolver()
41
    {
42
        return new $this->proxyResolverClass($this->resolver, $this->hosts);
43
    }
44
}
45