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

nette / latte / 8775682276

21 Apr 2024 09:37PM UTC coverage: 93.637% (+0.1%) from 93.539%
8775682276

push

github

dg
Engine: added underscore to template class

1 of 1 new or added line in 1 file covered. (100.0%)

30 existing lines in 2 files now uncovered.

5018 of 5359 relevant lines covered (93.64%)

0.94 hits per line

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

93.75
/src/Latte/Loaders/StringLoader.php
1
<?php
2

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

8
declare(strict_types=1);
9

10
namespace Latte\Loaders;
11

12
use Latte;
13

14

15
/**
16
 * Template loader.
17
 */
18
class StringLoader implements Latte\Loader
19
{
20
        /** @var string[]|null  [name => content] */
21
        private ?array $templates = null;
22

23

24
        /**
25
         * @param  string[]  $templates
26
         */
27
        public function __construct(?array $templates = null)
1✔
28
        {
29
                $this->templates = $templates;
1✔
30
        }
1✔
31

32

33
        /**
34
         * Returns template source code.
35
         */
36
        public function getContent(string $name): string
1✔
37
        {
38
                if ($this->templates === null) {
1✔
39
                        return $name;
1✔
40
                } elseif (isset($this->templates[$name])) {
1✔
41
                        return $this->templates[$name];
1✔
42
                } else {
43
                        throw new Latte\RuntimeException("Missing template '$name'.");
1✔
44
                }
45
        }
46

47

48
        public function isExpired(string $name, int $time): bool
49
        {
UNCOV
50
                return false;
×
51
        }
52

53

54
        /**
55
         * Returns referred template name.
56
         */
57
        public function getReferredName(string $name, string $referringName): string
1✔
58
        {
59
                if ($this->templates === null) {
1✔
60
                        throw new \LogicException("Missing template '$name'.");
1✔
61
                }
62

63
                return $name;
1✔
64
        }
65

66

67
        /**
68
         * Returns unique identifier for caching.
69
         */
70
        public function getUniqueId(string $name): string
1✔
71
        {
72
                return $this->getContent($name);
1✔
73
        }
74
}
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