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

nette / caching / 27920089981

21 Jun 2026 10:53PM UTC coverage: 87.348% (+0.1%) from 87.202%
27920089981

push

github

dg
added CLAUDE.md

573 of 656 relevant lines covered (87.35%)

0.87 hits per line

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

91.67
/src/Caching/OutputHelper.php
1
<?php declare(strict_types=1);
2

3
/**
4
 * This file is part of the Nette Framework (https://nette.org)
5
 * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
6
 */
7

8
namespace Nette\Caching;
9

10
use Nette;
11

12

13
/**
14
 * Output caching helper.
15
 */
16
class OutputHelper
17
{
18
        /** @var array<string, mixed> */
19
        public array $dependencies = [];
20

21

22
        public function __construct(
1✔
23
                private ?Cache $cache,
24
                private readonly mixed $key,
25
        ) {
26
                ob_start();
1✔
27
        }
1✔
28

29

30
        /**
31
         * Stops output buffering and saves the captured output to the cache.
32
         * @param  array<string, mixed>  $dependencies
33
         */
34
        public function end(array $dependencies = []): void
1✔
35
        {
36
                if ($this->cache === null) {
1✔
37
                        throw new Nette\InvalidStateException('Output cache has already been saved.');
×
38
                }
39

40
                $this->cache->save($this->key, ob_get_flush(), $dependencies + $this->dependencies);
1✔
41
                $this->cache = null;
1✔
42
        }
1✔
43

44

45
        /**
46
         * Stops and throws away the output.
47
         */
48
        public function rollback(): void
49
        {
50
                ob_end_flush();
1✔
51
                $this->cache = null;
1✔
52
        }
1✔
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