-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathTemplateEngineInterface.php
34 lines (31 loc) · 1.22 KB
/
TemplateEngineInterface.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
declare(strict_types=1);
namespace Flasher\Prime\Template;
/**
* TemplateEngineInterface - Contract for template rendering engines.
*
* This interface defines the essential operation for template rendering engines
* in PHPFlasher. Template engines are responsible for transforming template files
* into HTML content, particularly for notifications that require custom rendering.
*
* Design patterns:
* - Strategy: Defines a family of template rendering algorithms that can be used interchangeably
* - Adapter: Provides a common interface for different template engine implementations
*/
interface TemplateEngineInterface
{
/**
* Renders a template with the given context variables.
*
* This method transforms a template file or string into rendered HTML by
* substituting variables from the context array.
*
* @param string $name The template name/path to render
* @param array<string, mixed> $context Variables to pass to the template
*
* @return string The rendered template as a string
*
* @throws \InvalidArgumentException If the template cannot be found or parsed
*/
public function render(string $name, array $context = []): string;
}