• 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

55.0
/src/Service/PreloadCollector.php
1
<?php
2

3
namespace Tito10047\ProgressiveImageBundle\Service;
4

5
use Symfony\Component\HttpFoundation\RequestStack;
6
use Symfony\Component\WebLink\GenericLinkProvider;
7
use Symfony\Component\WebLink\Link;
8

9
class PreloadCollector {
10
        private array $urls = [];
11

12
        public function __construct(
13
                private readonly RequestStack $requestStack
14
        ) {
15
        }
258✔
16

17
        public function add(string $url, string $as = 'image', string $priority = 'high', ?string $srcset = null, ?string $sizes = null): void {
UNCOV
18
                $this->urls[$url] = [
28✔
UNCOV
19
                        'as' => $as,
28✔
UNCOV
20
                        'priority' => $priority,
28✔
UNCOV
21
                        'imagesrcset' => $srcset,
28✔
UNCOV
22
                        'imagesizes' => $sizes,
28✔
UNCOV
23
                ];
28✔
24

UNCOV
25
                $request = $this->requestStack->getCurrentRequest();
28✔
UNCOV
26
                if (!$request) {
28✔
UNCOV
27
                        return;
28✔
28
                }
29

30
                $link = (new Link('preload', $url))
×
31
                        ->withAttribute('as', $as)
×
32
                        ->withAttribute('fetchpriority', $priority);
×
33

34
                if ($srcset) {
×
35
                        $link = $link->withAttribute('imagesrcset', $srcset);
×
36
                }
37

38
                if ($sizes) {
×
39
                        $link = $link->withAttribute('imagesizes', $sizes);
×
40
                }
41

42
                $linkProvider = $request->attributes->get('_links', new GenericLinkProvider());
×
43
                $request->attributes->set('_links', $linkProvider->withLink($link));
×
44
        }
45

46
        public function getUrls(): array {
UNCOV
47
                return $this->urls;
84✔
48
        }
49
}
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