|
7 | 7 | use League\CommonMark\MarkdownConverter; |
8 | 8 | use Symfony\Component\Stopwatch\Stopwatch; |
9 | 9 |
|
10 | | -final readonly class CommonMark implements MarkdownInterface |
| 10 | +final class CommonMark implements MarkdownInterface |
11 | 11 | { |
12 | 12 | public function __construct( |
13 | | - private MarkdownConverter $textConverter, |
14 | | - private MarkdownConverter $textExtraConverter, |
15 | | - private MarkdownConverter $lineConverter, |
16 | | - private ?Stopwatch $stopwatch = null, |
| 13 | + private readonly MarkdownConverter $textConverter, |
| 14 | + private readonly MarkdownConverter $textExtraConverter, |
| 15 | + private readonly MarkdownConverter $lineConverter, |
| 16 | + private readonly ?Stopwatch $stopwatch = null |
17 | 17 | ) { |
18 | 18 | } |
19 | 19 |
|
20 | | - public function text(?string $markdown = null): string |
| 20 | + public function text(string $markdown = null): string |
21 | 21 | { |
22 | 22 | if (null === $markdown) { |
23 | 23 | return ''; |
24 | 24 | } |
25 | | - $this->stopwatch?->start(CommonMark::class.'::text'); |
| 25 | + $this->stopwatch?->start(CommonMark::class . '::text'); |
26 | 26 | $html = $this->textConverter->convert($markdown)->getContent(); |
27 | | - $this->stopwatch?->stop(CommonMark::class.'::text'); |
28 | | - |
| 27 | + $this->stopwatch?->stop(CommonMark::class . '::text'); |
29 | 28 | return $html; |
30 | 29 | } |
31 | 30 |
|
32 | | - public function textExtra(?string $markdown = null): string |
| 31 | + public function textExtra(string $markdown = null): string |
33 | 32 | { |
34 | 33 | if (null === $markdown) { |
35 | 34 | return ''; |
36 | 35 | } |
37 | | - $this->stopwatch?->start(CommonMark::class.'::textExtra'); |
| 36 | + $this->stopwatch?->start(CommonMark::class . '::textExtra'); |
38 | 37 | $html = $this->textExtraConverter->convert($markdown)->getContent(); |
39 | | - $this->stopwatch?->stop(CommonMark::class.'::textExtra'); |
40 | | - |
| 38 | + $this->stopwatch?->stop(CommonMark::class . '::textExtra'); |
41 | 39 | return $html; |
42 | 40 | } |
43 | 41 |
|
44 | | - public function line(?string $markdown = null): string |
| 42 | + public function line(string $markdown = null): string |
45 | 43 | { |
46 | 44 | if (null === $markdown) { |
47 | 45 | return ''; |
48 | 46 | } |
49 | | - $this->stopwatch?->start(CommonMark::class.'::line'); |
| 47 | + $this->stopwatch?->start(CommonMark::class . '::line'); |
50 | 48 | $html = $this->lineConverter->convert($markdown)->getContent(); |
51 | | - $this->stopwatch?->stop(CommonMark::class.'::line'); |
52 | | - |
| 49 | + $this->stopwatch?->stop(CommonMark::class . '::line'); |
53 | 50 | return $html; |
54 | 51 | } |
55 | 52 | } |
0 commit comments