Skip to content

Commit

Permalink
Change the "camelCase to underscore" method for `normalizeResourceTyp…
Browse files Browse the repository at this point in the history
…e()`
  • Loading branch information
cundd committed Jan 30, 2019
1 parent f2f9406 commit 556d3ff
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 2 additions & 6 deletions Classes/DataProvider/Utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,8 @@ private static function underscoredToUpperCamelCase($string)
*/
private static function camelCaseToLowerCaseUnderscored($input)
{
preg_match_all('!([A-Z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)!', $input, $matches);
$ret = $matches[0];
foreach ($ret as &$match) {
$match = $match == strtoupper($match) ? strtolower($match) : lcfirst($match);
}
$value = preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $input);

return implode('_', $ret);
return is_callable('mb_strtolower') ? mb_strtolower($value, 'utf-8') : strtolower($value);
}
}
4 changes: 4 additions & 0 deletions Tests/Unit/DataProvider/DataProviderUtilityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ public function normalizeResourceTypeDataProvider()
['MyExt-*', 'my_ext-*'],
['GeorgRinger-News-news', 'georg_ringer-news-news'],
['GeorgRinger-News-*', 'georg_ringer-news-*'],
['georgRinger-News-*', 'georg_ringer-news-*'],
['dCorn-Test-*', 'd_corn-test-*'],
['D', 'd'],
['d', 'd'],
];
}

Expand Down

0 comments on commit 556d3ff

Please sign in to comment.