Created
May 14, 2014 16:26
-
-
Save bakura10/addf7c07d71f0a0a63c5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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