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

nette / caching / 6311829630

26 Sep 2023 11:12AM UTC coverage: 88.889%. Remained the same
6311829630

push

github

dg
removed Nette\SmartObject

536 of 603 relevant lines covered (88.89%)

0.89 hits per line

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

92.86
/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
        private ?Cache $cache;
22
        private mixed $key;
23

24

25
        public function __construct(Cache $cache, mixed $key)
1✔
26
        {
27
                $this->cache = $cache;
1✔
28
                $this->key = $key;
1✔
29
                ob_start();
1✔
30
        }
1✔
31

32

33
        /**
34
         * Stops and saves the cache.
35
         */
36
        public function end(array $dependencies = []): void
1✔
37
        {
38
                if ($this->cache === null) {
1✔
39
                        throw new Nette\InvalidStateException('Output cache has already been saved.');
×
40
                }
41

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

46

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

© 2025 Coveralls, Inc