8000 Fixed singular of committee by peterrehm · Pull Request #18911 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refactored array to private static variable
  • Loading branch information
peterrehm committed Jun 5, 2016
commit 27eda6925f50eda57055ecf69626d3e3889d43e6
17 changes: 11 additions & 6 deletions src/Symfony/Component/PropertyAccess/StringUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,16 @@ class StringUtil
array('xuae', 4, false, true, 'eau'),
);

/**
* Irregular nouns which will not be converted 'ee' to 'oo'
*
* @var array
*/
private static $irregularNouns = array(
'committee' => 'committee',
'feedback' => 'feedback',
);

/**
* This class should not be instantiated.
*/
Expand Down Expand Up @@ -210,13 +220,8 @@ public static function singularify($plural)
}
}

$irregularNouns = array(
'committee' => 'committee',
'feedback' => 'feedback',
);

// Convert teeth to tooth, feet to foot
if (false !== ($pos = strpos($plural, 'ee')) && strlen($plural) > 3 && !isset($irregularNouns[strtolower($plural)])) {
if (false !== ($pos = strpos($plural, 'ee')) && strlen($plural) > 3 && !isset(self::$irregularNouns[strtolower($plural)])) {
return substr_replace($plural, 'oo', $pos, 2);
}

Expand Down
0