1 | <?php |
||
13 | class TemplateFactory implements TemplateFactoryInterface |
||
14 | { |
||
15 | |||
16 | /** |
||
17 | * @var string[] |
||
18 | */ |
||
19 | protected static $cachedTemplates = []; |
||
20 | |||
21 | /** |
||
22 | * @var array |
||
23 | */ |
||
24 | protected static $templates = [ |
||
25 | 'test' => [ |
||
26 | 'unit' => self::DEFAULT_TEMPLATE_DIR . 'test/unit.tpl', |
||
27 | ], |
||
28 | 'cest' => [ |
||
29 | 'integration' => self::DEFAULT_TEMPLATE_DIR . 'cest/integration.tpl', |
||
30 | ], |
||
31 | ]; |
||
32 | |||
33 | /** |
||
34 | * @var string |
||
35 | */ |
||
36 | protected $templatesPath; |
||
37 | |||
38 | /** |
||
39 | * TemplateFactory constructor. |
||
40 | * |
||
41 | * @param string $templatesPath |
||
42 | */ |
||
43 | public function __construct(string $templatesPath = self::DEFAULT_TEMPLATE_DIR) |
||
47 | |||
48 | /** |
||
49 | * @param string $name |
||
50 | * @param string $path |
||
51 | * |
||
52 | * @return bool |
||
53 | * @throws TemplateNotFound |
||
54 | */ |
||
55 | public static function registerTemplate(string $name, string $path) : bool |
||
63 | |||
64 | /** |
||
65 | * @param string $path |
||
66 | * |
||
67 | * @throws TemplateNotFound |
||
68 | */ |
||
69 | protected static function validateTemplatePath(string $path) |
||
75 | |||
76 | /** |
||
77 | * @param string $path |
||
78 | * |
||
79 | * @return TemplateInterface |
||
80 | * @throws FileNotFoundException |
||
81 | */ |
||
82 | public function getTemplate(string $path) : TemplateInterface |
||
86 | |||
87 | /** |
||
88 | * @param string $path |
||
89 | * |
||
90 | * @return string |
||
91 | * @throws FileNotFoundException |
||
92 | */ |
||
93 | private function resolveTemplate(string $path) : string |
||
100 | |||
101 | /** |
||
102 | * @param string $path |
||
103 | * |
||
104 | * @return string |
||
105 | */ |
||
106 | protected function resolveTemplatePath(string $path) : string |
||
110 | |||
111 | /** |
||
112 | * @param string $path |
||
113 | * |
||
114 | * @return string |
||
115 | */ |
||
116 | protected function prepareTemplatePath(string $path) : string |
||
122 | |||
123 | } |