TwigTemplateGenerator::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chemaclass\StockTicker\Domain\Notifier\Channel;
6
7
use Chemaclass\StockTicker\Domain\Notifier\NotifyResult;
8
use Twig;
9
10
final class TwigTemplateGenerator implements TemplateGeneratorInterface
11
{
12
    private Twig\Environment $twig;
13
14
    private string $templateName;
15
16
    public function __construct(Twig\Environment $twig, string $templateName)
17
    {
18
        $this->twig = $twig;
19
        $this->templateName = $templateName;
20
    }
21
22
    public function generateHtml(NotifyResult $notifyResult): string
23
    {
24
        return $this->twig->render(
25
            $this->templateName,
26
            [
27
                'notifyResult' => $notifyResult,
28
            ],
29
        );
30
    }
31
}
32