@@ -354,7 +354,7 @@ public static function helpPanel($usage, $commands = [], $options = [], $example
354354 * @param string $title
355355 * @return void
356356 */
357- public static function panel ($ data , $ title ='Info panel ' , $ char = '* ' )
357+ public static function panel ($ data , $ title ='Information Panel ' , $ char = '* ' )
358358 {
359359 $ data = is_array ($ data ) ? array_filter ($ data ) : [trim ($ data )];
360360 $ title = trim ($ title );
@@ -363,8 +363,6 @@ public static function panel($data, $title='Info panel', $char = '*')
363363 $ labelMaxWidth = 0 ; // if label exists, label max width
364364 $ valueMaxWidth = 0 ; // value max width
365365
366- self ::write ("\n " . sprintf (self ::STAR_LINE ,"<bold> $ title</bold> " ), false );
367-
368366 foreach ($ data as $ label => $ value ) {
369367 // label exists
370368 if ( !is_numeric ($ label ) ) {
@@ -377,11 +375,18 @@ public static function panel($data, $title='Info panel', $char = '*')
377375 $ temp = '' ;
378376
379377 foreach ($ value as $ key => $ val ) {
380- $ val = (string )$ val ;
381- $ temp .= (!is_numeric ($ key ) ? "$ key: " : '' ) . "<info> $ value</info>, " ;
378+ if (is_bool ($ val )) {
379+ $ val = $ val ? 'True ' : 'False ' ;
380+ } else {
381+ $ val = (string )$ val ;
382+ }
383+
384+ $ temp .= (!is_numeric ($ key ) ? "$ key: " : '' ) . "<info> $ val</info>, " ;
382385 }
383386
384387 $ value = rtrim ($ temp , ' , ' );
388+ } else if (is_bool ($ value )) {
389+ $ value = $ value ? 'True ' : 'False ' ;
385390 }
386391
387392 // get value width
@@ -390,6 +395,7 @@ public static function panel($data, $title='Info panel', $char = '*')
390395 $ width = mb_strlen (strip_tags ($ value ), 'UTF-8 ' ); // must clear style tag
391396 $ valueMaxWidth = $ width > $ valueMaxWidth ? $ width : $ valueMaxWidth ;
392397 } else {
398+ de ((string )$ value );
393399 throw new \Exception ('Panel data value only allow [array|string|number] ' );
394400 }
395401
@@ -402,12 +408,13 @@ public static function panel($data, $title='Info panel', $char = '*')
402408 if ($ title ) {
403409 $ title = ucwords ($ title );
404410 $ titleLength = mb_strlen ($ title , 'UTF-8 ' );
411+ $ panelWidth = $ panelWidth > $ titleLength ? $ panelWidth : $ titleLength ;
405412 $ indentSpace = str_pad (' ' , ceil ($ panelWidth /2 ) - ceil ($ titleLength /2 ) + 2 *2 , ' ' );
406413 self ::write (" {$ indentSpace }<bold> {$ title }</bold> " );
407414 }
408415
409416 // output panel top border
410- $ border = str_pad ($ char , $ panelWidth + (2 *3 ), $ char );
417+ $ border = str_pad ($ char , $ panelWidth + (3 *3 ), $ char );
411418 self ::write (' ' . $ border );
412419
413420 // output panel body
0 commit comments