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

tito10047 / progressive-image-bundle / 20660774589

02 Jan 2026 03:17PM UTC coverage: 88.816% (+0.8%) from 88.049%
20660774589

push

github

tito10047
add transparent HTML caching: implement caching for rendered image components, update services, configuration, tests, and documentation

39 of 40 new or added lines in 4 files covered. (97.5%)

63 existing lines in 6 files now uncovered.

540 of 608 relevant lines covered (88.82%)

160.76 hits per line

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

52.38
/src/Controller/LiipImagineController.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Tito10047\ProgressiveImageBundle\Controller;
6

7
use Tito10047\ProgressiveImageBundle\Service\LiipImagineRuntimeConfigGenerator;
8
use Liip\ImagineBundle\Config\Controller\ControllerConfig;
9
use Liip\ImagineBundle\Exception\Binary\Loader\NotLoadableException;
10
use Liip\ImagineBundle\Exception\Imagine\Filter\NonExistingFilterException;
11
use Liip\ImagineBundle\Imagine\Cache\Helper\PathHelper;
12
use Liip\ImagineBundle\Imagine\Data\DataManager;
13
use Liip\ImagineBundle\Imagine\Filter\FilterConfiguration;
14
use Liip\ImagineBundle\Service\FilterService;
15
use Symfony\Component\HttpFoundation\RedirectResponse;
16
use Symfony\Component\HttpFoundation\Request;
17
use Symfony\Component\HttpFoundation\Response;
18
use Symfony\Component\HttpFoundation\UriSigner;
19
use Symfony\Component\HttpKernel\Attribute\MapQueryParameter;
20
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
21
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
22

23
class LiipImagineController
24
{
25
        public function __construct(
26
                private readonly UriSigner  $signer,
27
                private readonly FilterService $filterService,
28
                private readonly DataManager $dataManager,
29
                private readonly FilterConfiguration $filterConfiguration,
30
                private readonly ControllerConfig $controllerConfig,
31
                private readonly LiipImagineRuntimeConfigGenerator $runtimeConfigGenerator,
32
        ) {
UNCOV
33
        }
56✔
34

35
        public function index(
36
                Request $request,
37
                #[MapQueryParameter] string $path,
38
                #[MapQueryParameter] int $width,
39
                #[MapQueryParameter] int $height,
40
                #[MapQueryParameter] ?string $filter = null,
41
        ): Response {
UNCOV
42
                $path = PathHelper::urlPathToFilePath($path);
56✔
43

UNCOV
44
                $result = $this->runtimeConfigGenerator->generate($width, $height, $filter);
56✔
UNCOV
45
                $filterName = $result['filterName'];
56✔
UNCOV
46
                $config = $result['config'];
56✔
47

UNCOV
48
                $this->filterConfiguration->set($filterName, $config);
56✔
49

UNCOV
50
                if (true !== $this->signer->checkRequest($request)) {
56✔
51
                        throw new BadRequestHttpException(\sprintf('Signed url does not pass the sign check for path "%s" and filter "%s"', $path, $filter));
×
52
                }
53

UNCOV
54
                return $this->createRedirectResponse(function () use ($path, $filterName, $request) {
56✔
UNCOV
55
                        return $this->filterService->getUrlOfFilteredImage($path, $filterName);
56✔
UNCOV
56
                }, $path, $filterName);
56✔
57
        }
58

59
        private function createRedirectResponse(\Closure $url, string $path, string $filter): RedirectResponse
60
        {
61
                try {
UNCOV
62
                        return new RedirectResponse($url(), $this->controllerConfig->getRedirectResponseCode());
56✔
63
                } catch (NotLoadableException $exception) {
×
64
                        if (null !== $this->dataManager->getDefaultImageUrl($filter)) {
×
65
                                return new RedirectResponse($this->dataManager->getDefaultImageUrl($filter));
×
66
                        }
67

68
                        throw new NotFoundHttpException(\sprintf('Source image for path "%s" could not be found', $path), $exception);
×
69
                } catch (NonExistingFilterException $exception) {
×
70
                        throw new NotFoundHttpException(\sprintf('Requested non-existing filter "%s"', $filter), $exception);
×
71
                } catch (\RuntimeException $exception) {
×
72
                        throw new \RuntimeException(\sprintf('Unable to create image for path "%s" and filter "%s". Message was "%s"', $path, $filter, $exception->getMessage()), 0, $exception);
×
73
                }
74
        }
75

76
        private function isWebpSupported(Request $request): bool
77
        {
78
                return false !== mb_stripos($request->headers->get('accept', ''), 'image/webp');
×
79
        }
80
}
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