• 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

90.0
/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\CacheInterface;
8
use Symfony\Contracts\Cache\ItemInterface;
9

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

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

24
    public function saveToCache(string $content, string $key): string
25
    {
26
        $this->cache->get($key, function (ItemInterface $item) use ($content) {
30✔
27
            if ($this->ttl) {
30✔
NEW
28
                $item->expiresAfter($this->ttl);
×
29
            }
30
            return $content;
30✔
31
        });
30✔
32

33
        return $content;
30✔
34
    }
35
}
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