Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/Illuminate/Support/Stringable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

/**
Expand Down
10 changes: 10 additions & 0 deletions tests/Support/SupportStringableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading