-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHtmlOutput.php
38 lines (32 loc) · 879 Bytes
/
HtmlOutput.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
35
36
37
38
<?php
namespace Felix\Tin\Outputs;
use Felix\Tin\Contracts\OutputInterface;
use Felix\Tin\Contracts\ThemeInterface;
use Felix\Tin\Enums\TokenType;
use Felix\Tin\Line;
readonly class HtmlOutput implements OutputInterface
{
public function __construct(
protected ThemeInterface $theme,
) {
}
public function transform(TokenType $type, string $value): string
{
return sprintf(
'<span style="color:rgb(%s);">%s</span>',
str_replace(';', ',', $this->theme->color($type)),
$value
);
}
public function theme(): ThemeInterface
{
return $this->theme;
}
public function transformLine(Line $line): string
{
return sprintf(
'<div class="line"><span class="line-number">%s</span>%s</div>',
$line->number, $line->toString()
);
}
}