Skip to content

Commit c334161

Browse files
committed
up: use Str::ucwords inteadof the ucwords()
1 parent eb1d449 commit c334161

File tree

5 files changed

+8
-10
lines changed

5 files changed

+8
-10
lines changed

src/Component/Formatter/Panel.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
use function rtrim;
2424
use function strip_tags;
2525
use function trim;
26-
use function ucwords;
2726
use const PHP_EOL;
2827

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

160159
// output title
161160
if ($title) {
162-
$title = ucwords($title);
161+
$title = Str::ucwords($title);
163162

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

258257
// output title
259258
if ($title) {
260-
$title = ucwords($title);
259+
$title = Str::ucwords($title);
260+
261261
$titleLength = mb_strlen($title, 'UTF-8');
262262
$panelWidth = $panelWidth > $titleLength ? $panelWidth : $titleLength;
263263
$indentSpace = Str::pad(' ', ceil($panelWidth / 2) - ceil($titleLength / 2) + 2 * 2, ' ');

src/Component/Formatter/Section.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use function implode;
1212
use function is_array;
1313
use function trim;
14-
use function ucwords;
1514
use const PHP_EOL;
1615

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

46-
$title = ucwords(trim($title));
45+
$title = Str::ucwords(trim($title));
4746
$tLength = Str::len($title);
4847
$width = $width > 10 ? $width : 80;
4948

src/Component/Formatter/SingleList.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
use Inhere\Console\Console;
77
use Inhere\Console\Util\FormatUtil;
88
use Toolkit\Cli\ColorTag;
9+
use Toolkit\Stdlib\Str;
910
use function array_merge;
1011
use function trim;
11-
use function ucwords;
1212
use const PHP_EOL;
1313

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

5151
// title
5252
if ($title) {
53-
$title = ucwords(trim($title));
53+
$title = Str::ucwords(trim($title));
5454
$string .= ColorTag::wrap($title, $opts['titleStyle']) . PHP_EOL;
5555
}
5656

src/Component/Formatter/Table.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
use function count;
2121
use function is_bool;
2222
use function is_string;
23-
use function ucwords;
2423

2524
/**
2625
* Class Table - Tabular data display
@@ -166,7 +165,7 @@ public static function show(array $data, string $title = 'Data Table', array $op
166165
// output title
167166
if ($title) {
168167
$tStyle = $opts['titleStyle'] ?: 'bold';
169-
$title = ucwords(trim($title));
168+
$title = Str::ucwords(trim($title));
170169
$titleLength = Str::utf8Len($title, 'UTF-8');
171170
$indentSpace = Str::pad(' ', ceil($tableWidth / 2) - ceil($titleLength / 2) + ($columnCount * 2), ' ');
172171
$buf->write(" {$indentSpace}<$tStyle>{$title}</$tStyle>\n");

src/Component/Formatter/Title.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public static function show(string $title, array $opts = []): void
4343
$indentStr = Str::pad(self::CHAR_SPACE, $indent, self::CHAR_SPACE);
4444
}
4545

46-
$title = $opts['ucWords'] ? ucwords(trim($title)) : trim($title);
46+
$title = $opts['ucWords'] ? Str::ucwords(trim($title)) : trim($title);
4747
$tLength = Str::len($title);
4848
$width = $width > 10 ? $width : 80;
4949

0 commit comments

Comments
 (0)