• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tito10047 / progressive-image-bundle / 20693585928

04 Jan 2026 01:24PM UTC coverage: 89.796%. Remained the same
20693585928

push

github

tito10047
cs fixer

704 of 784 relevant lines covered (89.8%)

252.6 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/UrlGenerator/LiipImagineResponsiveImageUrlGenerator.php
1
<?php
2

3
/*
4
 * This file is part of the Progressive Image Bundle.
5
 *
6
 * (c) Jozef Môstka <https://github.com/tito10047/progressive-image-bundle>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
declare(strict_types=1);
12

13
namespace Tito10047\ProgressiveImageBundle\UrlGenerator;
14

15
use Liip\ImagineBundle\Exception\Imagine\Filter\NonExistingFilterException;
16
use Liip\ImagineBundle\Imagine\Cache\CacheManager;
17
use Liip\ImagineBundle\Imagine\Filter\FilterConfiguration;
18
use Symfony\Component\HttpFoundation\UriSigner;
19
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
20
use Symfony\Contracts\Cache\TagAwareCacheInterface;
21
use Tito10047\ProgressiveImageBundle\Service\LiipImagineRuntimeConfigGeneratorInterface;
22

23
final class LiipImagineResponsiveImageUrlGenerator implements ResponsiveImageUrlGeneratorInterface
24
{
25
    public function __construct(
26
        private readonly CacheManager $cacheManager,
27
        private readonly UrlGeneratorInterface $router,
28
        private readonly UriSigner $uriSigner,
29
        private readonly LiipImagineRuntimeConfigGeneratorInterface $runtimeConfigGenerator,
30
        private readonly FilterConfiguration $filterConfiguration,
31
        private readonly ?TagAwareCacheInterface $cache,
32
        private readonly ?string $filter = null,
33
    ) {
34
    }
392✔
35

36
        public function generateUrl(string $path, int $targetW, ?int $targetH = null, ?string $pointInterest = null): string
37
    {
38
        $targetH = $targetH ?? $targetW;
238✔
39
        $result = $this->runtimeConfigGenerator->generate($targetW, $targetH, $this->filter, $pointInterest);
238✔
40
        $filterName = $result['filterName'];
238✔
41
        $config = $result['config'];
238✔
42

43
        // Register runtime filter so LiipImagine can find it
44
        try {
45
            $this->filterConfiguration->get($filterName);
238✔
46
        } catch (NonExistingFilterException) {
196✔
47
            $this->filterConfiguration->set($filterName, $config);
196✔
48
        }
49

50
        if ($this->cacheManager->isStored($path, $filterName)) {
238✔
51
                        $browserPath = $this->cacheManager->getBrowserPath($path, $filterName);
42✔
52

53
                        return str_replace('/resolve/', '/', $browserPath);
42✔
54
        }
55

56
        $this->cache?->invalidateTags(['pgi_tag_'.md5($path)]);
196✔
57

58
        $url = $this->router->generate('progressive_image_filter', [
196✔
59
            'path' => $path,
196✔
60
            'width' => $targetW,
196✔
61
            'height' => $targetH,
196✔
62
            'filter' => $this->filter,
196✔
63
            'pointInterest' => $pointInterest,
196✔
64
        ], UrlGeneratorInterface::ABSOLUTE_URL);
196✔
65

66
        return $this->uriSigner->sign($url);
196✔
67
    }
68
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc