| @@ 321-343 (lines=23) @@ | ||
| 318 | * @param $word |
|
| 319 | * @return bool|mixed |
|
| 320 | */ |
|
| 321 | protected function doPluralize($word) |
|
| 322 | { |
|
| 323 | $lowerCased_word = strtolower($word); |
|
| 324 | ||
| 325 | foreach ($this->uncountable as $_uncountable) { |
|
| 326 | if (substr($lowerCased_word, (-1 * strlen($_uncountable))) == $_uncountable) { |
|
| 327 | return $word; |
|
| 328 | } |
|
| 329 | } |
|
| 330 | ||
| 331 | foreach ($this->irregular as $_plural => $_singular) { |
|
| 332 | if (preg_match('/(' . $_plural . ')$/i', $word, $arr)) { |
|
| 333 | return preg_replace('/(' . $_plural . ')$/i', substr($arr[0], 0, 1) . substr($_singular, 1), $word); |
|
| 334 | } |
|
| 335 | } |
|
| 336 | ||
| 337 | foreach ($this->plural as $rule => $replacement) { |
|
| 338 | if (preg_match($rule, $word)) { |
|
| 339 | return preg_replace($rule, $replacement, $word); |
|
| 340 | } |
|
| 341 | } |
|
| 342 | ||
| 343 | return false; |
|
| 344 | } |
|
| 345 | ||
| 346 | /** |
|
| @@ 350-372 (lines=23) @@ | ||
| 347 | * @param $word |
|
| 348 | * @return mixed |
|
| 349 | */ |
|
| 350 | protected function doSingularize($word) |
|
| 351 | { |
|
| 352 | $lowercased_word = strtolower($word); |
|
| 353 | foreach ($this->uncountable as $_uncountable) { |
|
| 354 | if (substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable) { |
|
| 355 | return $word; |
|
| 356 | } |
|
| 357 | } |
|
| 358 | ||
| 359 | foreach ($this->irregular as $_plural => $_singular) { |
|
| 360 | if (preg_match('/(' . $_singular . ')$/i', $word, $arr)) { |
|
| 361 | return preg_replace('/(' . $_singular . ')$/i', substr($arr[0], 0, 1) . substr($_plural, 1), $word); |
|
| 362 | } |
|
| 363 | } |
|
| 364 | ||
| 365 | foreach ($this->singular as $rule => $replacement) { |
|
| 366 | if (preg_match($rule, $word)) { |
|
| 367 | return preg_replace($rule, $replacement, $word); |
|
| 368 | } |
|
| 369 | } |
|
| 370 | ||
| 371 | return $word; |
|
| 372 | } |
|
| 373 | ||
| 374 | /** |
|
| 375 | * @param $word |
|