Code Duplication    Length = 27-35 lines in 2 locations

Templating/FilterRuntime.php 1 location

@@ 18-44 (lines=27) @@
15
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
16
use Twig\Extension\RuntimeExtensionInterface;
17
18
class FilterRuntime implements RuntimeExtensionInterface
19
{
20
    /**
21
     * @var CacheManager
22
     */
23
    private $cache;
24
25
    public function __construct(CacheManager $cache)
26
    {
27
        $this->cache = $cache;
28
    }
29
30
    /**
31
     * Gets the browser path for the image and filter to apply.
32
     *
33
     * @param string      $path
34
     * @param string      $filter
35
     * @param string|null $resolver
36
     * @param int         $referenceType
37
     *
38
     * @return string
39
     */
40
    public function filter($path, $filter, array $config = [], $resolver = null, $referenceType = UrlGeneratorInterface::ABSOLUTE_URL)
41
    {
42
        return $this->cache->getBrowserPath(parse_url($path, PHP_URL_PATH), $filter, $config, $resolver, $referenceType);
43
    }
44
}
45

Templating/FilterTrait.php 1 location

@@ 19-53 (lines=35) @@
16
use Liip\ImagineBundle\Imagine\Cache\CacheManager;
17
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
18
19
trait FilterTrait
20
{
21
    /**
22
     * @var CacheManager
23
     */
24
    private $cache;
25
26
    public function __construct(CacheManager $cache)
27
    {
28
        $this->cache = $cache;
29
    }
30
31
    /**
32
     * Gets the browser path for the image and filter to apply.
33
     *
34
     * @param string      $path
35
     * @param string      $filter
36
     * @param string|null $resolver
37
     * @param int         $referenceType
38
     *
39
     * @return string
40
     */
41
    public function filter($path, $filter, array $config = [], $resolver = null, $referenceType = UrlGeneratorInterface::ABSOLUTE_URL)
42
    {
43
        return $this->cache->getBrowserPath(parse_url($path, PHP_URL_PATH), $filter, $config, $resolver, $referenceType);
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49
    public function getName()
50
    {
51
        return 'liip_imagine';
52
    }
53
}
54