35
35
class Panel extends MessageFormatter
36
36
{
37
37
/** @var string */
38
- public $ title = '' ;
38
+ public string $ title = '' ;
39
39
40
40
/** @var string */
41
- public $ titleBorder = '- ' ;
41
+ public string $ titleBorder = '- ' ;
42
42
43
43
/** @var string */
44
- public $ titleStyle = 'bold ' ;
44
+ public string $ titleStyle = 'bold ' ;
45
45
46
46
/** @var string */
47
- public $ titleAlign = self ::ALIGN_LEFT ;
47
+ public string $ titleAlign = self ::ALIGN_LEFT ;
48
48
49
49
/** @var string|array */
50
- public $ data ;
50
+ public string | array $ data ;
51
51
52
52
/** @var string */
53
- public $ bodyAlign = self ::ALIGN_LEFT ;
53
+ public string $ bodyAlign = self ::ALIGN_LEFT ;
54
54
55
55
/** @var string */
56
- public $ footerBorder = '- ' ;
56
+ public string $ footerBorder = '- ' ;
57
57
58
58
/** @var string */
59
- public $ footer = '' ;
59
+ public string $ footer = '' ;
60
60
61
61
/** @var bool */
62
- public $ ucFirst = true ;
62
+ public bool $ ucFirst = true ;
63
63
64
64
/** @var int */
65
- public $ width = 0 ;
65
+ public int $ width = 0 ;
66
66
67
67
/** @var bool */
68
- public $ showBorder = true ;
68
+ public bool $ showBorder = true ;
69
69
70
70
/** @var string */
71
- public $ borderYChar = '- ' ;
71
+ public string $ borderYChar = '- ' ;
72
72
73
73
/** @var string */
74
- public $ borderXChar = '| ' ;
74
+ public string $ borderXChar = '| ' ;
75
75
76
76
/**
77
77
* @var string Template for the panel. don't contains border
78
78
*/
79
- public $ template = <<<EOF
79
+ public string $ template = <<<EOF
80
80
{%title%}
81
81
{%title-border%}
82
82
{%content%}
@@ -93,7 +93,7 @@ class Panel extends MessageFormatter
93
93
*
94
94
* @return int
95
95
*/
96
- public static function show ($ data , string $ title = 'Information Panel ' , array $ opts = []): int
96
+ public static function show (mixed $ data , string $ title = 'Information Panel ' , array $ opts = []): int
97
97
{
98
98
if (!$ data ) {
99
99
Console::write ('<info>No data to display!</info> ' );
@@ -164,7 +164,7 @@ public static function show($data, string $title = 'Information Panel', array $o
164
164
$ titleLength = mb_strlen ($ title , 'UTF-8 ' );
165
165
$ panelWidth = $ panelWidth > $ titleLength ? $ panelWidth : $ titleLength ;
166
166
$ indentSpace = Str::pad (' ' , ceil ($ panelWidth / 2 ) - ceil ($ titleLength / 2 ) + 2 * 2 , ' ' );
167
- Console::write (" { $ indentSpace} <bold> { $ title} </bold> " );
167
+ Console::write (" $ indentSpace<bold> $ title</bold> " );
168
168
}
169
169
170
170
// output panel top border
@@ -226,7 +226,6 @@ public function format(): string
226
226
if (is_array ($ value )) {
227
227
$ temp = '' ;
228
228
229
- /** @var array $value */
230
229
foreach ($ value as $ key => $ val ) {
231
230
if (is_bool ($ val )) {
232
231
$ val = $ val ? 'True ' : 'False ' ;
@@ -262,7 +261,7 @@ public function format(): string
262
261
$ titleLength = mb_strlen ($ title , 'UTF-8 ' );
263
262
$ panelWidth = $ panelWidth > $ titleLength ? $ panelWidth : $ titleLength ;
264
263
$ indentSpace = Str::pad (' ' , ceil ($ panelWidth / 2 ) - ceil ($ titleLength / 2 ) + 2 * 2 , ' ' );
265
- $ buffer ->write (" { $ indentSpace} <bold> { $ title} </bold> \n" );
264
+ $ buffer ->write (" $ indentSpace<bold> $ title</bold> \n" );
266
265
}
267
266
268
267
// output panel top border
@@ -297,7 +296,7 @@ public function format(): string
297
296
*
298
297
* @return $this
299
298
*/
300
- public function showBorder ($ border ): self
299
+ public function showBorder (bool $ border ): self
301
300
{
302
301
$ this ->showBorder = (bool )$ border ;
303
302
return $ this ;
0 commit comments