| Conditions | 5 |
| Paths | 5 |
| Total Lines | 16 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 6 |
| CRAP Score | 6.6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 34 | 28 | public function getEngineInstance($templateFile) : AbstractEngine |
|
| 35 | { |
||
| 36 | 28 | foreach($this->extensions as $extension => $factory) { |
|
| 37 | 28 | if($extension == substr($templateFile, -strlen($extension))) { |
|
| 38 | 28 | if(is_a($factory, EngineFactoryInterface::class)) { |
|
| 39 | 28 | $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 | 28 | return $engine; |
|
| 46 | } |
||
| 47 | } |
||
| 48 | |||
| 49 | throw new TemplateEngineNotFoundException("An engine for rendering the {$templateFile} extension was not found."); |
||
| 50 | } |
||
| 52 |