1 | <?php |
||
18 | class TemplateFactory implements TemplateFactoryInterface |
||
19 | { |
||
20 | |||
21 | /** |
||
22 | * @var string[] |
||
23 | */ |
||
24 | protected static $cachedTemplates = []; |
||
25 | |||
26 | /** |
||
27 | * @var array |
||
28 | */ |
||
29 | protected static $templates = [ |
||
30 | 'test' => [ |
||
31 | 'unit' => self::DEFAULT_TEMPLATE_DIR . 'test/unit.tpl', |
||
32 | ], |
||
33 | 'cest' => [ |
||
34 | 'integration' => self::DEFAULT_TEMPLATE_DIR . 'cest/integration.tpl', |
||
35 | 'graphql' => self::DEFAULT_TEMPLATE_DIR . 'cest/graphql.tpl', |
||
36 | ], |
||
37 | ]; |
||
38 | |||
39 | /** |
||
40 | * @var string |
||
41 | */ |
||
42 | protected $templatesPath; |
||
43 | |||
44 | /** |
||
45 | * TemplateFactory constructor. |
||
46 | * |
||
47 | * @param string $templatesPath |
||
48 | */ |
||
49 | public function __construct(string $templatesPath = self::DEFAULT_TEMPLATE_DIR) |
||
53 | |||
54 | /** |
||
55 | * @param string $name |
||
56 | * @param string $path |
||
57 | * |
||
58 | * @return bool |
||
59 | * @throws TemplateNotFound |
||
60 | */ |
||
61 | public static function registerTemplate(string $name, string $path) : bool |
||
69 | |||
70 | /** |
||
71 | * @param string $path |
||
72 | * |
||
73 | * @throws TemplateNotFound |
||
74 | */ |
||
75 | protected static function validateTemplatePath(string $path) |
||
81 | |||
82 | /** |
||
83 | * @param string $path |
||
84 | * |
||
85 | * @return TemplateInterface |
||
86 | * @throws FileNotFoundException |
||
87 | */ |
||
88 | public function getTemplate(string $path) : TemplateInterface |
||
92 | |||
93 | /** |
||
94 | * @param string $path |
||
95 | * |
||
96 | * @return string |
||
97 | * @throws FileNotFoundException |
||
98 | */ |
||
99 | private function resolveTemplate(string $path) : string |
||
106 | |||
107 | /** |
||
108 | * @param string $path |
||
109 | * |
||
110 | * @return string |
||
111 | */ |
||
112 | protected function resolveTemplatePath(string $path) : string |
||
116 | |||
117 | /** |
||
118 | * @param string $path |
||
119 | * |
||
120 | * @return string |
||
121 | */ |
||
122 | protected function prepareTemplatePath(string $path) : string |
||
128 | |||
129 | } |
||
130 |