diff --git a/src/Illuminate/Support/Pluralizer.php b/src/Illuminate/Support/Pluralizer.php index 6cc55ad7b885..75a2f6ac31d6 100755 --- a/src/Illuminate/Support/Pluralizer.php +++ b/src/Illuminate/Support/Pluralizer.php @@ -64,7 +64,7 @@ class Pluralizer */ public static function plural($value, $count = 2) { - if ((int) $count === 1 || static::uncountable($value)) { + if ((int) abs($count) === 1 || static::uncountable($value)) { return $value; } diff --git a/tests/Support/SupportPluralizerTest.php b/tests/Support/SupportPluralizerTest.php index 78635d44a97f..71de8db32e30 100755 --- a/tests/Support/SupportPluralizerTest.php +++ b/tests/Support/SupportPluralizerTest.php @@ -39,4 +39,11 @@ public function testIfEndOfWordPlural() $this->assertEquals('IndexFields', Str::plural('IndexField')); $this->assertEquals('VertexFields', Str::plural('VertexField')); } + + public function testPluralWithNegativeCount() { + $this->assertEquals('test', Str::plural('test', 1)); + $this->assertEquals('tests', Str::plural('test', 2)); + $this->assertEquals('test', Str::plural('test', -1)); + $this->assertEquals('tests', Str::plural('test', -2)); + } }