| Conditions | 5 |
| Paths | 5 |
| Total Lines | 16 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 34 | public function getEngineInstance($templateFile) : AbstractEngine |
||
| 35 | { |
||
| 36 | foreach($this->extensions as $extension => $factory) { |
||
| 37 | if($extension == substr($templateFile, -strlen($extension))) { |
||
| 38 | if(is_a($factory, EngineFactoryInterface::class)) { |
||
| 39 | $engine = $factory->create(); |
||
| 40 | } else if (is_callable($factory)) { |
||
| 41 | $engine = $factory(); |
||
| 42 | } else { |
||
| 43 | throw new FactoryException("There is no factory for creating engines for the {$extension} extension"); |
||
| 44 | } |
||
| 45 | return $engine; |
||
| 46 | } |
||
| 47 | } |
||
| 48 | |||
| 49 | throw new TemplateEngineNotFoundException("An engine for rendering the {$templateFile} extension was not found."); |
||
| 50 | } |
||
| 52 |