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

nette / latte / 22359082277

24 Feb 2026 04:03PM UTC coverage: 93.959% (+0.05%) from 93.907%
22359082277

push

github

dg
fixed operator ! priority

5273 of 5612 relevant lines covered (93.96%)

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

10
use Latte;
11

12

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

21

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

30

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

45

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

51

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

61
                return $name;
1✔
62
        }
63

64

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