| 1 |
<?php |
| 2 |
|
| 3 |
namespace Monei\Templates; |
| 4 |
|
| 5 |
class TemplateManager { |
| 6 |
|
| 7 |
/** |
| 8 |
* @var TemplateInterface[] |
| 9 |
*/ |
| 10 |
private array $templates = array(); |
| 11 |
|
| 12 |
/** |
| 13 |
* @param TemplateInterface[] $templates Keyed array of templateName => TemplateInstance |
| 14 |
*/ |
| 15 |
public function __construct( array $templates ) { |
| 16 |
$this->templates = $templates; |
| 17 |
} |
| 18 |
|
| 19 |
/** |
| 20 |
* Retrieve the template instance by name. |
| 21 |
* |
| 22 |
* @param string $templateName |
| 23 |
* @return TemplateInterface|null |
| 24 |
*/ |
| 25 |
public function getTemplate( string $templateName ): ?TemplateInterface { |
| 26 |
return $this->templates[ $templateName ] ?? null; |
| 27 |
} |
| 28 |
} |
| 29 |
|