Skip to content

Commit 2fdbd1c

Browse files
Add explicit tests, update docblock for Str::pluralStudly (#39726)
1 parent 5b50d53 commit 2fdbd1c

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/Illuminate/Support/Str.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ public static function plural($value, $count = 2)
533533
* Pluralize the last word of an English, studly caps case string.
534534
*
535535
* @param string $value
536-
* @param int $count
536+
* @param int|array|\Countable $count
537537
* @return string
538538
*/
539539
public static function pluralStudly($value, $count = 2)

tests/Support/SupportPluralizerTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,20 @@ public function testPluralSupportsCollections()
9999
$this->assertSame('users', Str::plural('user', collect(['one', 'two'])));
100100
}
101101

102+
public function testPluralStudlySupportsArrays()
103+
{
104+
$this->assertPluralStudly('SomeUsers', 'SomeUser', []);
105+
$this->assertPluralStudly('SomeUser', 'SomeUser', ['one']);
106+
$this->assertPluralStudly('SomeUsers', 'SomeUser', ['one', 'two']);
107+
}
108+
109+
public function testPluralStudlySupportsCollections()
110+
{
111+
$this->assertPluralStudly('SomeUsers', 'SomeUser', collect());
112+
$this->assertPluralStudly('SomeUser', 'SomeUser', collect(['one']));
113+
$this->assertPluralStudly('SomeUsers', 'SomeUser', collect(['one', 'two']));
114+
}
115+
102116
private function assertPluralStudly($expected, $value, $count = 2)
103117
{
104118
$this->assertSame($expected, Str::pluralStudly($value, $count));

0 commit comments

Comments
 (0)