From c11cb0a540dce4753ce40994738462a8ee8bd646 Mon Sep 17 00:00:00 2001
From: "Ralph J. Smit" <59207045+ralphjsmit@users.noreply.github.com>
Date: Sat, 8 Jan 2022 21:06:39 +0100
Subject: [PATCH 1/4] Document Str::substrReplace() methods
---
helpers.md | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/helpers.md b/helpers.md
index 85d18b6259..d1a922281d 100644
--- a/helpers.md
+++ b/helpers.md
@@ -132,6 +132,7 @@ Laravel includes a variety of global "helper" PHP functions. Many of these funct
[Str::studly](#method-studly-case)
[Str::substr](#method-str-substr)
[Str::substrCount](#method-str-substrcount)
+[Str::substr](#method-str-substrreplace)
[Str::title](#method-title-case)
[Str::toHtmlString](#method-to-html-string)
[Str::ucfirst](#method-str-ucfirst)
@@ -199,6 +200,7 @@ Laravel includes a variety of global "helper" PHP functions. Many of these funct
[startsWith](#method-fluent-str-starts-with)
[studly](#method-fluent-str-studly)
[substr](#method-fluent-str-substr)
+[substr](#method-fluent-str-substrreplace)
[tap](#method-fluent-str-tap)
[test](#method-fluent-str-test)
[title](#method-fluent-str-title)
@@ -1697,6 +1699,20 @@ The `Str::substrCount` method returns the number of occurrences of a given value
// 2
+
+#### `Str::substrReplace()` {.collection-method}
+
+The `Str::substrReplace` method replaces text within a portion of a string, starting at the position specified in the third argument and replacing the specified number of characters from the fourth argument. Setting the number of characters to replace to `0` will insert the string at the specified position:
+
+ use Illuminate\Support\Str;
+
+ $result = Str::substrReplace('1300', ':', 2);
+ // 13:
+
+ $result = Str::substrReplace('1300', ':', 2, 0);
+ // 13:00
+
+
#### `Str::title()` {.collection-method}
@@ -2506,6 +2522,21 @@ The `substr` method returns the portion of the string specified by the given sta
// Frame
+
+#### `substrReplace` {.collection-method}
+
+The `substrReplace` method replaces text within a portion of a string, starting at the position specified in the second argument and replacing the specified number of characters set with the third argument. Setting the number of characters to replace to `0` will insert the string at the specified position:
+
+ use Illuminate\Support\Str;
+
+ $string = Str::of('1300')->substrReplace(':', 2, 0);
+
+ // 13:00
+
+ $string = Str::of('The Framework')->substrReplace(' Laravel', 3, 0);
+
+ // The Laravel Framework
+
#### `tap` {.collection-method}
From b6f9453347f0e1a3e3bc9f8932da9a409b422351 Mon Sep 17 00:00:00 2001
From: "Ralph J. Smit" <59207045+ralphjsmit@users.noreply.github.com>
Date: Sat, 8 Jan 2022 21:08:01 +0100
Subject: [PATCH 2/4] Update index
---
helpers.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/helpers.md b/helpers.md
index d1a922281d..6ad25d556c 100644
--- a/helpers.md
+++ b/helpers.md
@@ -132,7 +132,7 @@ Laravel includes a variety of global "helper" PHP functions. Many of these funct
[Str::studly](#method-studly-case)
[Str::substr](#method-str-substr)
[Str::substrCount](#method-str-substrcount)
-[Str::substr](#method-str-substrreplace)
+[Str::substrReplace](#method-str-substrreplace)
[Str::title](#method-title-case)
[Str::toHtmlString](#method-to-html-string)
[Str::ucfirst](#method-str-ucfirst)
@@ -200,7 +200,7 @@ Laravel includes a variety of global "helper" PHP functions. Many of these funct
[startsWith](#method-fluent-str-starts-with)
[studly](#method-fluent-str-studly)
[substr](#method-fluent-str-substr)
-[substr](#method-fluent-str-substrreplace)
+[substrReplace](#method-fluent-str-substrreplace)
[tap](#method-fluent-str-tap)
[test](#method-fluent-str-test)
[title](#method-fluent-str-title)
From 062fb5fb731e0e38b3070796cbdea2446d9d3c26 Mon Sep 17 00:00:00 2001
From: "Ralph J. Smit" <59207045+ralphjsmit@users.noreply.github.com>
Date: Sat, 8 Jan 2022 21:10:23 +0100
Subject: [PATCH 3/4] Remove a black line too much
---
helpers.md | 1 -
1 file changed, 1 deletion(-)
diff --git a/helpers.md b/helpers.md
index 6ad25d556c..c74a1c6c0c 100644
--- a/helpers.md
+++ b/helpers.md
@@ -1711,7 +1711,6 @@ The `Str::substrReplace` method replaces text within a portion of a string, star
$result = Str::substrReplace('1300', ':', 2, 0);
// 13:00
-
#### `Str::title()` {.collection-method}
From 1d1077ed2d65b17acdc18ba2c1fc867f3bcc4cdf Mon Sep 17 00:00:00 2001
From: Taylor Otwell
Date: Mon, 10 Jan 2022 08:27:20 -0600
Subject: [PATCH 4/4] Update helpers.md
---
helpers.md | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/helpers.md b/helpers.md
index c74a1c6c0c..5a17d59394 100644
--- a/helpers.md
+++ b/helpers.md
@@ -1702,7 +1702,7 @@ The `Str::substrCount` method returns the number of occurrences of a given value
#### `Str::substrReplace()` {.collection-method}
-The `Str::substrReplace` method replaces text within a portion of a string, starting at the position specified in the third argument and replacing the specified number of characters from the fourth argument. Setting the number of characters to replace to `0` will insert the string at the specified position:
+The `Str::substrReplace` method replaces text within a portion of a string, starting at the position specified by the third argument and replacing the number of characters specified by the fourth argument. Passing `0` to the method's fourth argument will insert the string at the specified position without replacing any of the existing characters in the string:
use Illuminate\Support\Str;
@@ -2524,13 +2524,13 @@ The `substr` method returns the portion of the string specified by the given sta
#### `substrReplace` {.collection-method}
-The `substrReplace` method replaces text within a portion of a string, starting at the position specified in the second argument and replacing the specified number of characters set with the third argument. Setting the number of characters to replace to `0` will insert the string at the specified position:
+The `substrReplace` method replaces text within a portion of a string, starting at the position specified by the third argument and replacing the number of characters specified by the fourth argument. Passing `0` to the method's fourth argument will insert the string at the specified position without replacing any of the existing characters in the string:
use Illuminate\Support\Str;
- $string = Str::of('1300')->substrReplace(':', 2, 0);
+ $string = Str::of('1300')->substrReplace(':', 2);
- // 13:00
+ // 13:
$string = Str::of('The Framework')->substrReplace(' Laravel', 3, 0);