Completed
Pull Request — 2.x (#1360)
by
unknown
04:30 queued 02:57
created

ResolveCacheHandler::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
/*
4
 * This file is part of the `liip/LiipImagineBundle` project.
5
 *
6
 * (c) https://github.com/liip/LiipImagineBundle/graphs/contributors
7
 *
8
 * For the full copyright and license information, please view the LICENSE.md
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Liip\ImagineBundle\Message\Handler;
13
14
use Liip\ImagineBundle\Imagine\Filter\FilterManager;
15
use Liip\ImagineBundle\Message\ResolveCache;
16
use Liip\ImagineBundle\Service\FilterService;
17
use Symfony\Component\Messenger\Handler\MessageHandlerInterface;
18
19
/** @experimental */
20
class ResolveCacheHandler implements MessageHandlerInterface
21
{
22
    /** @var FilterManager */
23
    private $filterManager;
24
25
    /** @var FilterService */
26
    private $filterService;
27
28
    public function __construct(FilterManager $filterManager, FilterService $filterService)
29
    {
30
        $this->filterManager = $filterManager;
31
        $this->filterService = $filterService;
32
    }
33
34
    public function __invoke(ResolveCache $message): void
35
    {
36
        $filters = $message->getFilters() ?: array_keys($this->filterManager->getFilterConfiguration()->all());
37
        $path = $message->getPath();
38
39 View Code Duplication
        foreach ($filters as $filter) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
40
            if ($message->isForce()) {
41
                $this->filterService->bustCache($path, $filter);
42
            }
43
44
            $this->filterService->getUrlOfFilteredImage($path, $filter);
45
        }
46
    }
47
}
48