Skip to content

Instantly share code, notes, and snippets.

@bakura10
Created May 14, 2014 16:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bakura10/addf7c07d71f0a0a63c5 to your computer and use it in GitHub Desktop.
Save bakura10/addf7c07d71f0a0a63c5 to your computer and use it in GitHub Desktop.
class UnderscoreNamingStrategy implements NamingStrategyInterface
{
/**
* {@inheritDoc}
*/
public function getNameForExtraction($name, $context = null)
{
return ltrim(strtolower(preg_replace('/[A-Z]/', '_$0', $name)), '_');
}
/**
* {@inheritDoc}
*/
public function getNameForHydration($name, $context = null)
{
return lcfirst(str_replace(' ', '', ucwords(str_replace('_', ' ', strtolower($name)))));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment