composer package updates
[openemr.git] / vendor / illuminate / support / Pluralizer.php
blob6cc55ad7b885498ce3505bc6a5942125df2a6847
1 <?php
3 namespace Illuminate\Support;
5 use Doctrine\Common\Inflector\Inflector;
7 class Pluralizer
9 /**
10 * Uncountable word forms.
12 * @var array
14 public static $uncountable = [
15 'audio',
16 'bison',
17 'cattle',
18 'chassis',
19 'compensation',
20 'coreopsis',
21 'data',
22 'deer',
23 'education',
24 'emoji',
25 'equipment',
26 'evidence',
27 'feedback',
28 'firmware',
29 'fish',
30 'furniture',
31 'gold',
32 'hardware',
33 'information',
34 'jedi',
35 'kin',
36 'knowledge',
37 'love',
38 'metadata',
39 'money',
40 'moose',
41 'news',
42 'nutrition',
43 'offspring',
44 'plankton',
45 'pokemon',
46 'police',
47 'rain',
48 'rice',
49 'series',
50 'sheep',
51 'software',
52 'species',
53 'swine',
54 'traffic',
55 'wheat',
58 /**
59 * Get the plural form of an English word.
61 * @param string $value
62 * @param int $count
63 * @return string
65 public static function plural($value, $count = 2)
67 if ((int) $count === 1 || static::uncountable($value)) {
68 return $value;
71 $plural = Inflector::pluralize($value);
73 return static::matchCase($plural, $value);
76 /**
77 * Get the singular form of an English word.
79 * @param string $value
80 * @return string
82 public static function singular($value)
84 $singular = Inflector::singularize($value);
86 return static::matchCase($singular, $value);
89 /**
90 * Determine if the given value is uncountable.
92 * @param string $value
93 * @return bool
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
105 * @return string
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);
117 return $value;