Skip to content

Commit a9a44f2

Browse files
committed
Utility: Review Str
- Rename `Str::wrap()` to `Str::enclose()` - Rename `Str::wordwrap()` to `Str::wrap()`
1 parent bb7671b commit a9a44f2

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

src/Toolkit/Console/ConsoleFormatter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,12 +544,12 @@ function (array $match) use (
544544
}
545545
if ($wrapToWidth !== null) {
546546
if (strlen($break) === 1) {
547-
$string = Str::wordwrap($string, $wrapToWidth, $break);
547+
$string = Str::wrap($string, $wrapToWidth, $break);
548548
} else {
549549
if (strpos($string, "\x7f") !== false) {
550550
$string = $this->insertPlaceholders($string, '/\x7f/', $replace);
551551
}
552-
$string = Str::wordwrap($string, $wrapToWidth, "\x7f");
552+
$string = Str::wrap($string, $wrapToWidth, "\x7f");
553553
$string = $this->insertPlaceholders($string, '/\x7f/', $replace, "\n", $break);
554554
}
555555
}

src/Toolkit/Utility/Format.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ public static function date(
147147
$format .= ' H:i:s T';
148148
}
149149

150-
return Str::wrap($date->format($format), $before, $after);
150+
return Str::enclose($date->format($format), $before, $after);
151151
}
152152

153153
/**
@@ -207,9 +207,9 @@ public static function dateRange(
207207

208208
return sprintf(
209209
'%s%s%s',
210-
Str::wrap($from->format($fromFormat), $before, $after),
210+
Str::enclose($from->format($fromFormat), $before, $after),
211211
$delimiter,
212-
Str::wrap($to->format($toFormat), $before, $after),
212+
Str::enclose($to->format($toFormat), $before, $after),
213213
);
214214
}
215215

src/Toolkit/Utility/Str.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ public static function splitDelimited(
529529
*
530530
* @param array{int,int}|int $width
531531
*/
532-
public static function wordwrap(
532+
public static function wrap(
533533
string $string,
534534
$width = 75,
535535
string $break = "\n",
@@ -605,7 +605,7 @@ public static function unwrap(
605605
* @param string|null $after If `null`, `$before` is used before and after
606606
* the string.
607607
*/
608-
public static function wrap(string $string, string $before, ?string $after = null): string
608+
public static function enclose(string $string, string $before, ?string $after = null): string
609609
{
610610
return $before . $string . ($after ?? $before);
611611
}

tests/unit/Toolkit/Utility/StrTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -665,11 +665,11 @@ public function splitDelimitedProvider(): array
665665
];
666666
}
667667

668-
public function testWrap(): void
668+
public function testEnclose(): void
669669
{
670-
$this->assertEquals('**test**', Str::wrap('test', '**'));
671-
$this->assertEquals('[test]', Str::wrap('test', '[', ']'));
672-
$this->assertEquals('!!test?', Str::wrap('test', '!!', '?'));
670+
$this->assertEquals('**test**', Str::enclose('test', '**'));
671+
$this->assertEquals('[test]', Str::enclose('test', '[', ']'));
672+
$this->assertEquals('!!test?', Str::enclose('test', '!!', '?'));
673673
}
674674

675675
/**

0 commit comments

Comments
 (0)