Skip to content

Commit

Permalink
revert
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Jan 9, 2018
1 parent 75158f9 commit ce88b25
Showing 1 changed file with 64 additions and 2 deletions.
66 changes: 64 additions & 2 deletions src/Illuminate/Support/Pluralizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,55 @@

class Pluralizer
{
/**
* Uncountable word forms.
*
* @var array
*/
public static $uncountable = [
'audio',
'bison',
'cattle',
'chassis',
'compensation',
'coreopsis',
'data',
'deer',
'education',
'emoji',
'equipment',
'evidence',
'feedback',
'firmware',
'fish',
'furniture',
'gold',
'hardware',
'information',
'jedi',
'kin',
'knowledge',
'love',
'metadata',
'money',
'moose',
'news',
'nutrition',
'offspring',
'plankton',
'pokemon',
'police',
'rain',
'rice',
'series',
'sheep',
'software',
'species',
'swine',
'traffic',
'wheat',
];

/**
* Get the plural form of an English word.
*
Expand All @@ -15,11 +64,13 @@ class Pluralizer
*/
public static function plural($value, $count = 2)
{
if ((int) $count === 1) {
if ((int) $count === 1 || static::uncountable($value)) {
return $value;
}

return static::matchCase(Inflector::pluralize($value), $value);
$plural = Inflector::pluralize($value);

return static::matchCase($plural, $value);
}

/**
Expand All @@ -35,6 +86,17 @@ public static function singular($value)
return static::matchCase($singular, $value);
}

/**
* Determine if the given value is uncountable.
*
* @param string $value
* @return bool
*/
protected static function uncountable($value)
{
return in_array(strtolower($value), static::$uncountable);
}

/**
* Attempt to match the case on two strings.
*
Expand Down

0 comments on commit ce88b25

Please sign in to comment.