Skip to content

Commit

Permalink
[5.2] Update Str::plural() to use intval() (laravel#14502)
Browse files Browse the repository at this point in the history
* Update Str::plural() to use intval()

A lot of the time when you use str_plural() you get the $count value from a form request which returns the number as a string and therefore this plural won't work as expected. This small change should make sure the $count is in integer format.

Thanks to @barryvdh for suggesting to do this change deeper in the code.

* Changed to type casting

Using `(int) $count` instead of `intval($count)` as requested.
  • Loading branch information
SaeedPrez authored and tillkruss committed Aug 30, 2016
1 parent 01cf6b2 commit f134d3d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Illuminate/Support/Pluralizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Pluralizer
*/
public static function plural($value, $count = 2)
{
if ($count === 1 || static::uncountable($value)) {
if ((int) $count === 1 || static::uncountable($value)) {
return $value;
}

Expand Down

0 comments on commit f134d3d

Please sign in to comment.