1 | <?php |
||
26 | final class Loader implements LoaderInterface |
||
27 | { |
||
28 | /** |
||
29 | * Get the file contents of a template. |
||
30 | * |
||
31 | * @param string $name Template. |
||
32 | * |
||
33 | * @return string |
||
34 | */ |
||
35 | 4 | public function getSource($name): string |
|
41 | |||
42 | /** |
||
43 | * Returns the source context for a given template logical name. |
||
44 | * |
||
45 | * @param string $name The template logical name. |
||
46 | * |
||
47 | * @throws \WyriHaximus\TwigView\Lib\Twig\Twig\Error\Loader When $name is not found |
||
48 | * @return \WyriHaximus\TwigView\Lib\Twig\Twig\Source |
||
49 | * |
||
50 | */ |
||
51 | 2 | public function getSourceContext($name): Source |
|
58 | |||
59 | /** |
||
60 | * Get cache key for template. |
||
61 | * |
||
62 | * @param string $name Template. |
||
63 | * |
||
64 | * @return string |
||
65 | */ |
||
66 | 5 | public function getCacheKey($name): string |
|
70 | |||
71 | /** |
||
72 | * Check if template is still fresh. |
||
73 | * |
||
74 | * @param string $name Template. |
||
75 | * @param int $time Timestamp. |
||
76 | * |
||
77 | * @return bool |
||
78 | */ |
||
79 | 2 | public function isFresh($name, $time): bool |
|
85 | |||
86 | /** |
||
87 | * Check if we have the source code of a template, given its name. |
||
88 | * |
||
89 | * @param string $name The name of the template to check if we can load. |
||
90 | * |
||
91 | * @return bool If the template source code is handled by this loader or not. |
||
92 | */ |
||
93 | public function exists($name): bool |
||
102 | |||
103 | /** |
||
104 | * Resolve template name to filename. |
||
105 | * |
||
106 | * @param string $name Template. |
||
107 | * |
||
108 | * @throws \Twig\Error\LoaderError Thrown when template file isn't found. |
||
109 | * @return string |
||
110 | * |
||
111 | */ |
||
112 | 9 | private function resolveFileName($name): string |
|
121 | |||
122 | /** |
||
123 | * Get template filename. |
||
124 | * |
||
125 | * @param string $name Template. |
||
126 | * |
||
127 | * @return string|false |
||
128 | * |
||
129 | */ |
||
130 | 9 | private function getFilename($name) |
|
154 | |||
155 | /** |
||
156 | * Check if $plugin is active and return it's template paths or return the aps template paths. |
||
157 | * |
||
158 | * @param string|null $plugin The plugin in question. |
||
159 | * |
||
160 | * @return array |
||
161 | */ |
||
162 | 6 | private function getPaths($plugin): array |
|
170 | } |
||
171 |
This check looks for type mismatches where the missing type is
false
. This is usually indicative of an error condtion.Consider the follow example
This function either returns a new
DateTime
object or false, if there was an error. This is a typical pattern in PHP programming to show that an error has occurred without raising an exception. The calling code should check for this returnedfalse
before passing on the value to another function or method that may not be able to handle afalse
.