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

tito10047 / progressive-image-bundle / 20674769022

03 Jan 2026 08:26AM UTC coverage: 86.782% (-2.3%) from 89.065%
20674769022

push

github

tito10047
add tag-aware cache support: implement usage of `TagAwareCacheInterface` in cache services, update bundle configurations, compiler pass, tests, and Twig templates; ensure compatibility with non-tag-aware caches

47 of 70 new or added lines in 6 files covered. (67.14%)

604 of 696 relevant lines covered (86.78%)

175.71 hits per line

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

85.71
/src/Twig/TransparentCacheExtension.php
1
<?php
2

3
namespace Tito10047\ProgressiveImageBundle\Twig;
4

5
use Twig\Extension\AbstractExtension;
6
use Twig\TwigFilter;
7
use Symfony\Contracts\Cache\TagAwareCacheInterface;
8
use Symfony\Contracts\Cache\ItemInterface;
9

10
class TransparentCacheExtension extends AbstractExtension
11
{
12
    public function __construct(
13
        private readonly ?TagAwareCacheInterface $cache,
14
        private readonly ?int $ttl
15
    ) {}
217✔
16

17
    public function getFilters(): array
18
    {
19
        return [
30✔
20
            new TwigFilter('pgi_cache_save', [$this, 'saveToCache'], ['is_safe' => ['html']]),
30✔
21
        ];
30✔
22
    }
23

24
    public function saveToCache(string $content, string $key, ?string $tag = null): string
25
    {
26
        if (!$this->cache) {
158✔
NEW
27
            return $content;
×
28
        }
29

30
        $this->cache->get($key, function (ItemInterface $item) use ($content, $tag) {
158✔
31
            if ($this->ttl) {
158✔
32
                $item->expiresAfter($this->ttl);
×
33
            }
34
            if ($tag) {
158✔
35
                $item->tag($tag);
158✔
36
            }
37
            return $content;
158✔
38
        });
158✔
39

40
        return $content;
158✔
41
    }
42
}
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