Skip to content

Commit

Permalink
up: use Str::ucwords inteadof the ucwords()
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Apr 19, 2021
1 parent eb1d449 commit c334161
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/Component/Formatter/Panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
use function rtrim;
use function strip_tags;
use function trim;
use function ucwords;
use const PHP_EOL;

/**
Expand Down Expand Up @@ -159,7 +158,7 @@ public static function show($data, string $title = 'Information Panel', array $o

// output title
if ($title) {
$title = ucwords($title);
$title = Str::ucwords($title);

$titleLength = mb_strlen($title, 'UTF-8');
$panelWidth = $panelWidth > $titleLength ? $panelWidth : $titleLength;
Expand Down Expand Up @@ -257,7 +256,8 @@ public function format(): string

// output title
if ($title) {
$title = ucwords($title);
$title = Str::ucwords($title);

$titleLength = mb_strlen($title, 'UTF-8');
$panelWidth = $panelWidth > $titleLength ? $panelWidth : $titleLength;
$indentSpace = Str::pad(' ', ceil($panelWidth / 2) - ceil($titleLength / 2) + 2 * 2, ' ');
Expand Down
3 changes: 1 addition & 2 deletions src/Component/Formatter/Section.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use function implode;
use function is_array;
use function trim;
use function ucwords;
use const PHP_EOL;

/**
Expand Down Expand Up @@ -43,7 +42,7 @@ public static function show(string $title, $body, array $opts = []): void
$indent = (int)$opts['indent'] >= 0 ? $opts['indent'] : 2;
$indentStr = Str::pad(self::CHAR_SPACE, $indent, self::CHAR_SPACE);

$title = ucwords(trim($title));
$title = Str::ucwords(trim($title));
$tLength = Str::len($title);
$width = $width > 10 ? $width : 80;

Expand Down
4 changes: 2 additions & 2 deletions src/Component/Formatter/SingleList.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
use Inhere\Console\Console;
use Inhere\Console\Util\FormatUtil;
use Toolkit\Cli\ColorTag;
use Toolkit\Stdlib\Str;
use function array_merge;
use function trim;
use function ucwords;
use const PHP_EOL;

/**
Expand Down Expand Up @@ -50,7 +50,7 @@ public static function show($data, string $title = 'Information', array $opts =

// title
if ($title) {
$title = ucwords(trim($title));
$title = Str::ucwords(trim($title));
$string .= ColorTag::wrap($title, $opts['titleStyle']) . PHP_EOL;
}

Expand Down
3 changes: 1 addition & 2 deletions src/Component/Formatter/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use function count;
use function is_bool;
use function is_string;
use function ucwords;

/**
* Class Table - Tabular data display
Expand Down Expand Up @@ -166,7 +165,7 @@ public static function show(array $data, string $title = 'Data Table', array $op
// output title
if ($title) {
$tStyle = $opts['titleStyle'] ?: 'bold';
$title = ucwords(trim($title));
$title = Str::ucwords(trim($title));
$titleLength = Str::utf8Len($title, 'UTF-8');
$indentSpace = Str::pad(' ', ceil($tableWidth / 2) - ceil($titleLength / 2) + ($columnCount * 2), ' ');
$buf->write(" {$indentSpace}<$tStyle>{$title}</$tStyle>\n");
Expand Down
2 changes: 1 addition & 1 deletion src/Component/Formatter/Title.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static function show(string $title, array $opts = []): void
$indentStr = Str::pad(self::CHAR_SPACE, $indent, self::CHAR_SPACE);
}

$title = $opts['ucWords'] ? ucwords(trim($title)) : trim($title);
$title = $opts['ucWords'] ? Str::ucwords(trim($title)) : trim($title);
$tLength = Str::len($title);
$width = $width > 10 ? $width : 80;

Expand Down

0 comments on commit c334161

Please sign in to comment.