| @@ 67-81 (lines=15) @@ | ||
| 64 | * @param string $plural Plural form of word; function will attempt to deduce plural form from singular if not provided |
|
| 65 | * @return string Pluralized word if quantity is not one, otherwise singular |
|
| 66 | */ |
|
| 67 | public static function pluralize($quantity, $singular, $plural = null) |
|
| 68 | { |
|
| 69 | if ($quantity == 1 || !strlen($singular)) return $singular; |
|
| 70 | if ($plural !== null) return $plural; |
|
| 71 | ||
| 72 | $last_letter = strtolower($singular[strlen($singular) - 1]); |
|
| 73 | switch ($last_letter) { |
|
| 74 | case 'y': |
|
| 75 | return substr($singular, 0, -1) . 'ies'; |
|
| 76 | case 's': |
|
| 77 | return $singular . 'es'; |
|
| 78 | default: |
|
| 79 | return $singular . 's'; |
|
| 80 | } |
|
| 81 | } |
|
| 82 | ||
| 83 | public function addComplexType(\ReflectionClass $refClass, $name, $namespace = null, $baseResourceType = null) |
|
| 84 | { |
|
| @@ 109-123 (lines=15) @@ | ||
| 106 | * @param string $plural Plural form of word; function will attempt to deduce plural form from singular if not provided |
|
| 107 | * @return string Pluralized word if quantity is not one, otherwise singular |
|
| 108 | */ |
|
| 109 | public static function pluralize($quantity, $singular, $plural = null) |
|
| 110 | { |
|
| 111 | if ($quantity == 1 || !strlen($singular)) return $singular; |
|
| 112 | if ($plural !== null) return $plural; |
|
| 113 | ||
| 114 | $last_letter = strtolower($singular[strlen($singular) - 1]); |
|
| 115 | switch ($last_letter) { |
|
| 116 | case 'y': |
|
| 117 | return substr($singular, 0, -1) . 'ies'; |
|
| 118 | case 's': |
|
| 119 | return $singular . 'es'; |
|
| 120 | default: |
|
| 121 | return $singular . 's'; |
|
| 122 | } |
|
| 123 | } |
|
| 124 | } |
|
| 125 | ||