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

nette / caching / 20531391949

26 Dec 2025 11:47PM UTC coverage: 87.202% (-0.1%) from 87.316%
20531391949

push

github

dg
used attribute Deprecated

586 of 672 relevant lines covered (87.2%)

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
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
declare(strict_types=1);
9

10
namespace Nette\Caching;
11

12
use Nette;
13

14

15
/**
16
 * Output caching helper.
17
 */
18
class OutputHelper
19
{
20
        public array $dependencies = [];
21

22

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

30

31
        /**
32
         * Stops and saves the cache.
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