diff --git a/src/Illuminate/Support/Stringable.php b/src/Illuminate/Support/Stringable.php index 21fbe3fff860..67c4b9b5ddd5 100644 --- a/src/Illuminate/Support/Stringable.php +++ b/src/Illuminate/Support/Stringable.php @@ -1110,11 +1110,12 @@ public function ucfirst() /** * Capitalize the first character of each word in a string. * + * @param string $separators * @return static */ - public function ucwords() + public function ucwords($separators = " \t\r\n\f\v") { - return new static(Str::ucwords($this->value)); + return new static(Str::ucwords($this->value, $separators)); } /** diff --git a/tests/Support/SupportStringableTest.php b/tests/Support/SupportStringableTest.php index 8302193c596f..56dd427dd1da 100644 --- a/tests/Support/SupportStringableTest.php +++ b/tests/Support/SupportStringableTest.php @@ -180,6 +180,16 @@ public function testCanBeLimitedByWords() $this->assertSame('Taylor Otwell', (string) $this->stringable('Taylor Otwell')->words(3)); } + public function testUcwords() + { + $this->assertSame('Laravel', (string) $this->stringable('laravel')->ucwords()); + $this->assertSame('Laravel Framework', (string) $this->stringable('laravel framework')->ucwords()); + $this->assertSame('Laravel-Framework', (string) $this->stringable('laravel-framework')->ucwords('-')); + $this->assertSame('Мама', (string) $this->stringable('мама')->ucwords()); + $this->assertSame('Мама Мыла Раму', (string) $this->stringable('мама мыла раму')->ucwords()); + $this->assertSame('JJ Watt', (string) $this->stringable('JJ watt')->ucwords()); + } + public function testUnless() { $this->assertSame('unless false', (string) $this->stringable('unless')->unless(false, function ($stringable, $value) {