1 | <?php |
||
17 | final class DynamicStringLoader implements ILoader |
||
18 | { |
||
19 | /** |
||
20 | * @var array [name => content] |
||
21 | */ |
||
22 | private $templates = []; |
||
23 | |||
24 | 6 | public function addTemplate(string $name, string $content) |
|
28 | |||
29 | /** |
||
30 | * {@inheritdoc} |
||
31 | */ |
||
32 | 5 | public function getContent($name) : string |
|
33 | { |
||
34 | 5 | if (isset($this->templates[$name])) { |
|
35 | 4 | return $this->templates[$name]; |
|
36 | } |
||
37 | |||
38 | 1 | throw new \RuntimeException( |
|
39 | 1 | sprintf('Missing template "%s".', $name) |
|
40 | ); |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * {@inheritdoc} |
||
45 | */ |
||
46 | 1 | public function isExpired($name, $time) : bool |
|
47 | { |
||
48 | // needed? |
||
49 | 1 | return false; |
|
50 | } |
||
51 | |||
52 | /** |
||
53 | * {@inheritdoc} |
||
54 | */ |
||
55 | 2 | public function getReferredName($name, $referringName) : string |
|
60 | |||
61 | /** |
||
62 | * {@inheritdoc} |
||
63 | */ |
||
64 | 4 | public function getUniqueId($name) |
|
69 | } |
||
70 |