15
15
use App \Service \Toolkit \ToolkitService ;
16
16
use Symfony \Component \Filesystem \Filesystem ;
17
17
use Symfony \Component \Filesystem \Path ;
18
- use Symfony \Component \String \AbstractString ;
19
18
use Symfony \UX \Toolkit \Recipe \Recipe ;
20
19
use Symfony \UX \TwigComponent \Attribute \AsTwigComponent ;
21
20
@@ -29,15 +28,15 @@ class ComponentDoc
29
28
30
29
public function __construct (
31
30
private readonly Filesystem $ filesystem ,
32
- private readonly ToolkitService $ toolkitService
31
+ private readonly ToolkitService $ toolkitService,
33
32
) {
34
33
}
35
34
36
35
public function getContent (): string
37
36
{
38
37
$ examples = $ this ->getExamples ();
39
38
40
- return $ this ->adaptPreviewableCodeBlocks (sprintf (<<<MARKDOWN
39
+ return $ this ->adaptPreviewableCodeBlocks (\ sprintf (<<<MARKDOWN
41
40
# %s
42
41
43
42
%s
@@ -60,9 +59,9 @@ public function getContent(): string
60
59
$ this ->component ->manifest ->description ,
61
60
current ($ examples ),
62
61
$ this ->toolkitService ->renderInstallationSteps ($ this ->kitId , $ this ->component ),
63
- dump (preg_replace ('/^```twig.*\n/ ' , '```twig ' .PHP_EOL , current ($ examples ))),
62
+ dump (preg_replace ('/^```twig.*\n/ ' , '```twig ' .\ PHP_EOL , current ($ examples ))),
64
63
array_reduce (array_keys ($ examples ), function (string $ acc , string $ exampleTitle ) use ($ examples ) {
65
- $ acc .= '### ' .$ exampleTitle .PHP_EOL .$ examples [$ exampleTitle ].PHP_EOL ;
64
+ $ acc .= '### ' .$ exampleTitle .\ PHP_EOL .$ examples [$ exampleTitle ].\ PHP_EOL ;
66
65
67
66
return $ acc ;
68
67
}, '' )
@@ -83,19 +82,19 @@ private function getExamples(): array
83
82
84
83
// Split the markdown for each title and content
85
84
$ examples = [];
86
- foreach (explode (PHP_EOL , $ markdown ) as $ line ) {
85
+ foreach (explode (\ PHP_EOL , $ markdown ) as $ line ) {
87
86
if (str_starts_with ($ line , '## ' )) {
88
87
// This is a new example title
89
88
$ title = trim (substr ($ line , 2 ));
90
89
$ examples [$ title ] = '' ;
91
90
} elseif (isset ($ title )) {
92
91
// This line belongs to the last example
93
- $ examples [$ title ] .= $ line .PHP_EOL ;
92
+ $ examples [$ title ] .= $ line .\ PHP_EOL ;
94
93
}
95
94
}
96
95
97
96
if ([] === $ examples ) {
98
- throw new \LogicException (sprintf ('No examples found in "%s". ' , $ examplesMdPath ));
97
+ throw new \LogicException (\ sprintf ('No examples found in "%s". ' , $ examplesMdPath ));
99
98
}
100
99
101
100
foreach ($ examples as $ title => &$ example ) {
@@ -118,7 +117,7 @@ private function adaptPreviewableCodeBlocks(string $markdownContent): string
118
117
$ options ['kit ' ] = $ this ->kitId ->value ;
119
118
}
120
119
121
- return \sprintf ('```%s %s ' .PHP_EOL , $ lang , json_encode ($ options , \JSON_THROW_ON_ERROR ));
120
+ return \sprintf ('```%s %s ' .\ PHP_EOL , $ lang , json_encode ($ options , \JSON_THROW_ON_ERROR ));
122
121
})->toString ();
123
122
}
124
123
}
0 commit comments