From 7966e37cfe2372a3e6fa46f70f1a74b4534ac26c Mon Sep 17 00:00:00 2001 From: Travis Elkins Date: Mon, 31 Aug 2020 15:23:51 +0200 Subject: [PATCH] Updated docs to reflect new string padding methods. (#6283) --- helpers.md | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/helpers.md b/helpers.md index cc31a40737..ceeae5e516 100644 --- a/helpers.md +++ b/helpers.md @@ -103,6 +103,9 @@ Laravel includes a variety of global "helper" PHP functions. Many of these funct [Str::limit](#method-str-limit) [Str::lower](#method-str-lower) [Str::orderedUuid](#method-str-ordered-uuid) +[Str::padBoth](#method-str-padboth) +[Str::padLeft](#method-str-padleft) +[Str::padRight](#method-str-padright) [Str::plural](#method-str-plural) [Str::random](#method-str-random) [Str::replaceArray](#method-str-replace-array) @@ -156,6 +159,9 @@ Laravel includes a variety of global "helper" PHP functions. Many of these funct [ltrim](#method-fluent-str-ltrim) [match](#method-fluent-str-match) [matchAll](#method-fluent-str-match-all) +[padBoth](#method-fluent-str-padboth) +[padLeft](#method-fluent-str-padleft) +[padRight](#method-fluent-str-padright) [plural](#method-fluent-str-plural) [prepend](#method-fluent-str-prepend) [replace](#method-fluent-str-replace) @@ -1276,6 +1282,51 @@ The `Str::orderedUuid` method generates a "timestamp first" UUID that may be eff return (string) Str::orderedUuid(); + +#### `Str::padBoth()` {#collection-method} + +The `Str::padBoth` method wraps PHP's `str_pad` function, padding both sides of a string with another: + + use Illuminate\Support\Str; + + $padded = Str::padBoth('Alien', 10, '_'); + + // '__Alien___' + + $padded = Str::padBoth('Alien', 10); + + // ' Alien ' + + +#### `Str::padLeft()` {#collection-method} + +The `Str::padLeft` method wraps PHP's `str_pad` function, padding the left side of a string with another: + + use Illuminate\Support\Str; + + $padded = Str::padLeft('Alien', 10, '-='); + + // '-=-=-Alien' + + $padded = Str::padLeft('Alien', 10); + + // ' Alien' + + +#### `Str::padRight()` {#collection-method} + +The `Str::padRight` method wraps PHP's `str_pad` function, padding the right side of a string with another: + + use Illuminate\Support\Str; + + $padded = Str::padRight('Alien', 10, '-'); + + // 'Alien-----' + + $padded = Str::padRight('Alien', 10); + + // 'Alien ' + #### `Str::plural()` {#collection-method} @@ -1877,6 +1928,51 @@ If you specify a matching group within the expression, Laravel will return a col If no matches are found, an empty collection will be returned. + +#### `padBoth` {#collection-method} + +The `padBoth` method wraps PHP's `str_pad` function, padding both sides of a string with another: + + use Illuminate\Support\Str; + + $padded = Str::of('Alien')->padBoth(10, '_'); + + // '__Alien___' + + $padded = Str::of('Alien')->padBoth(10); + + // ' Alien ' + + +#### `padLeft` {#collection-method} + +The `padLeft` method wraps PHP's `str_pad` function, padding the left side of a string with another: + + use Illuminate\Support\Str; + + $padded = Str::of('Alien')->padLeft(10, '-='); + + // '-=-=-Alien' + + $padded = Str::of('Alien')->padLeft(10); + + // ' Alien' + + +#### `padRight` {#collection-method} + +The `padRight` method wraps PHP's `str_pad` function, padding the right side of a string with another: + + use Illuminate\Support\Str; + + $padded = Str::of('Alien')->padRight(10, '-'); + + // 'Alien-----' + + $padded = Str::of('Alien')->padRight(10); + + // 'Alien ' + #### `plural` {#collection-method}