3 namespace Illuminate\Support
;
5 use Doctrine\Common\Inflector\Inflector
;
10 * Uncountable word forms.
14 public static $uncountable = [
59 * Get the plural form of an English word.
61 * @param string $value
65 public static function plural($value, $count = 2)
67 if ((int) $count === 1 ||
static::uncountable($value)) {
71 $plural = Inflector
::pluralize($value);
73 return static::matchCase($plural, $value);
77 * Get the singular form of an English word.
79 * @param string $value
82 public static function singular($value)
84 $singular = Inflector
::singularize($value);
86 return static::matchCase($singular, $value);
90 * Determine if the given value is uncountable.
92 * @param string $value
95 protected static function uncountable($value)
97 return in_array(strtolower($value), static::$uncountable);
101 * Attempt to match the case on two strings.
103 * @param string $value
104 * @param string $comparison
107 protected static function matchCase($value, $comparison)
109 $functions = ['mb_strtolower', 'mb_strtoupper', 'ucfirst', 'ucwords'];
111 foreach ($functions as $function) {
112 if (call_user_func($function, $comparison) === $comparison) {
113 return call_user_func($function, $value);