@@ -26,28 +26,32 @@ public function __construct(bool $verbose = false, ?SymfonyOutput $output = null
26
26
public function printStartMessage (string $ host , int $ port ): void
27
27
{
28
28
$ title = 'HydePHP Realtime Compiler ' ;
29
- $ version = ' v ' .Hyde::version ();
29
+ $ version = 'v ' .Hyde::version ();
30
30
31
31
$ url = sprintf ('%s://%s:%d ' , $ port === 443 ? 'https ' : 'http ' , $ host , $ port );
32
32
33
- $ width = max (strlen ("$ title $ version " ), strlen ("Listening on $ url " ) + 1 ) + 1 ;
34
- $ spacing = str_repeat (' ' , $ width );
35
- $ lines = str_repeat ('─ ' , $ width );
36
-
37
- $ line1 = ' ' .sprintf ('<span class="text-blue-500">%s</span> <span class="text-gray">%s</span> ' , $ title , $ version ).str_repeat (' ' , $ width - strlen ("$ title $ version " ));
38
- $ line2 = ' ' .sprintf ('<span class="text-white">Listening on </span> <a href="%s" class="text-yellow-500">%s</a> ' , $ url , $ url ).str_repeat (' ' , $ width - strlen ("Listening on $ url " ) - 1 );
39
- render (<<<HTML
40
- <div class="text-green-500">
41
- <br>
42
- ╭ {$ lines }╮<br>
43
- │ {$ spacing }│<br>
44
- │ {$ line1 }│<br>
45
- │ {$ spacing }│<br>
46
- │ {$ line2 }│<br>
47
- │ {$ spacing }│<br>
48
- ╰ {$ lines }╯<br>
49
- </div>
50
- HTML );
33
+ $ lines = [
34
+ sprintf ('<span class="text-blue-500">%s</span> <span class="text-gray">%s</span> ' , $ title , $ version ),
35
+ '' ,
36
+ sprintf ('<span class="text-white">Listening on</span> <a href="%s" class="text-yellow-500">%s</a> ' , $ url , $ url ),
37
+ ];
38
+
39
+ $ lineLength = max (array_map ('strlen ' , array_map ('strip_tags ' , $ lines )));
40
+
41
+ $ lines = array_map (function (string $ line ) use ($ lineLength ): string {
42
+ return sprintf (' │ <span class="text-white">%s</span>%s│ ' ,
43
+ $ line , str_repeat (' ' , ($ lineLength - strlen (strip_tags ($ line ))) + 1 )
44
+ );
45
+ }, array_merge (['' ], $ lines , ['' ]));
46
+
47
+ $ topLine = sprintf (' ╭%s╮ ' , str_repeat ('─ ' , $ lineLength + 2 ));
48
+ $ bottomLine = sprintf (' ╰%s╯ ' , str_repeat ('─ ' , $ lineLength + 2 ));
49
+
50
+ $ lines = array_merge ([$ topLine ], $ lines , [$ bottomLine ]);
51
+
52
+ $ body = implode ('<br> ' , array_merge (['' ], $ lines , ['' ]));
53
+
54
+ render ("<div class= \"text-green-500 \"> $ body</div> " );
51
55
}
52
56
53
57
public function getFormatter (): Closure
0 commit comments