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

tito10047 / progressive-image-bundle / 20661725623

02 Jan 2026 04:11PM UTC coverage: 89.065%. Remained the same
20661725623

push

github

tito10047
replace `grid` with `sizes`: update all references in templates, tests, and documentation to align with the new attribute name; adjust `Image` component logic accordingly and ensure backward compatibility

1 of 1 new or added line in 1 file covered. (100.0%)

111 existing lines in 9 files now uncovered.

562 of 631 relevant lines covered (89.06%)

166.02 hits per line

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

100.0
/src/Event/KernelResponseEventListener.php
1
<?php
2

3
namespace Tito10047\ProgressiveImageBundle\Event;
4

5
use Tito10047\ProgressiveImageBundle\Service\PreloadCollector;
6
use Symfony\Component\HttpKernel\Event\ResponseEvent;
7

8
class KernelResponseEventListener {
9

10
        public function __construct(
11
                private readonly PreloadCollector $preloadCollector,
12
        ) { }
143✔
13

14
        public function __invoke(ResponseEvent $event) {
15
                $response = $event->getResponse();
143✔
16

17
                $preloads = $this->preloadCollector->getUrls();
143✔
18
                if (empty($preloads)) return;
143✔
19

20
                $links = [];
58✔
21
                foreach ($preloads as $url => $attr) {
58✔
22
                        $link = sprintf('<%s>; rel=preload; as=%s; fetchpriority=%s',
58✔
23
                                $url, $attr['as'], $attr['priority']);
58✔
24
                        if (!empty($attr['imagesrcset'])) {
58✔
UNCOV
25
                                $link .= sprintf('; imagesrcset="%s"', $attr['imagesrcset']);
14✔
26
                        }
27
                        if (!empty($attr['imagesizes'])) {
58✔
UNCOV
28
                                $link .= sprintf('; imagesizes="%s"', $attr['imagesizes']);
14✔
29
                        }
30
                        $links[] = $link;
58✔
31
                }
32
                $response->headers->set('Link', implode(', ', $links), false);
58✔
33

34
                $content = $response->getContent();
58✔
35

36
                $html = "";
58✔
37
                foreach ($preloads as $url => $attr) {
58✔
38
                        $html .= sprintf('<link rel="preload" href="%s" as="%s" fetchpriority="%s"',
58✔
39
                                $url, $attr['as'], $attr['priority']);
58✔
40
                        if (!empty($attr['imagesrcset'])) {
58✔
UNCOV
41
                                $html .= sprintf(' imagesrcset="%s"', $attr['imagesrcset']);
14✔
42
                        }
43
                        if (!empty($attr['imagesizes'])) {
58✔
UNCOV
44
                                $html .= sprintf(' imagesizes="%s"', $attr['imagesizes']);
14✔
45
                        }
46
                        $html .= '>';
58✔
47
                }
48

49
                $newContent = str_replace('</head>', $html . '</head>', $content);
58✔
50
                $response->setContent($newContent);
58✔
51
        }
52

53
}
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