1 | <?php |
||
11 | class FilesystemLoader implements TemplateLoaderInterface { |
||
12 | /** |
||
13 | * @var string |
||
14 | */ |
||
15 | private $basePath; |
||
16 | |||
17 | 26 | public function __construct($basePath) { |
|
20 | |||
21 | /** |
||
22 | * Return the cache key of a component. |
||
23 | * |
||
24 | * @param string $component The name of the component. |
||
25 | * @return string Returns the unique key of the component. |
||
26 | */ |
||
27 | 26 | public function cacheKey($component) { |
|
36 | |||
37 | /** |
||
38 | * Return the template source of a component. |
||
39 | * |
||
40 | * @param string $component The name of the component. |
||
41 | * @return string Returns the template source of the component. |
||
|
|||
42 | */ |
||
43 | 25 | public function load($component) { |
|
52 | |||
53 | 26 | private function componentPath($component, $full = true) { |
|
54 | 26 | $subpath = str_replace('.', DIRECTORY_SEPARATOR, $component); |
|
55 | |||
56 | do { |
||
57 | 26 | $path = "{$this->basePath}/$subpath.html"; |
|
58 | 26 | if (file_exists($path)) { |
|
59 | 26 | return $full ? $path : $subpath; |
|
60 | } |
||
61 | |||
62 | if ($pos = strrpos($subpath, DIRECTORY_SEPARATOR)) { |
||
63 | $subpath = substr($subpath, 0, $pos - 1); |
||
64 | } else { |
||
65 | break; |
||
66 | } |
||
67 | |||
68 | } while (!empty($subpath)); |
||
69 | |||
70 | return ''; |
||
71 | } |
||
72 | |||
73 | /** |
||
74 | * Get the basePath. |
||
75 | * |
||
76 | * @return string Returns the basePath. |
||
77 | */ |
||
78 | public function getBasePath() { |
||
81 | |||
82 | /** |
||
83 | * Set the basePath. |
||
84 | * |
||
85 | * @param string $basePath |
||
86 | * @return $this |
||
87 | */ |
||
88 | public function setBasePath($basePath) { |
||
92 | } |
||
93 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.