Total Complexity | 4 |
Total Lines | 50 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
13 | final class DynamicContent |
||
14 | { |
||
15 | private string $id; |
||
16 | private array $parameters; |
||
17 | |||
18 | /** |
||
19 | * @var callable |
||
20 | */ |
||
21 | private $contentGenerator; |
||
22 | |||
23 | /** |
||
24 | * @param string $id The unique identifier of the dynamic content. |
||
25 | * @param callable $contentGenerator PHP callable with the signature: `function (array $parameters = []): string;`. |
||
26 | * @param array $parameters The parameters (name-value pairs) that will be passed in the $contentGenerator context. |
||
27 | */ |
||
28 | 5 | public function __construct(string $id, callable $contentGenerator, array $parameters = []) |
|
29 | { |
||
30 | 5 | $this->id = $id; |
|
31 | 5 | $this->contentGenerator = $contentGenerator; |
|
32 | 5 | $this->parameters = $parameters; |
|
33 | 5 | } |
|
34 | |||
35 | /** |
||
36 | * Returns the he unique identifier of the dynamic content. |
||
37 | * |
||
38 | * @return string The unique identifier of the dynamic content. |
||
39 | */ |
||
40 | 5 | public function id(): string |
|
43 | } |
||
44 | |||
45 | /** |
||
46 | * Generates the dynamic content. |
||
47 | * |
||
48 | * @return string The generated dynamic content. |
||
49 | */ |
||
50 | 5 | public function content(): string |
|
53 | } |
||
54 | |||
55 | /** |
||
56 | * Returns the placeholder of the dynamic content. |
||
57 | * |
||
58 | * @return string The placeholder of the dynamic content. |
||
59 | */ |
||
60 | 5 | public function placeholder(): string |
|
63 | } |
||
64 | } |
||
65 |