library/Garp/Util/String.php
static public function camelcasedToUnderscored($str) {
        $str = lcfirst($str);
        return preg_replace_callback(
            '/([A-Z])/',
            function ($str) {
                return "_" . strtolower($str[1]);
            },
            $str
        );
    }
static public function camelcasedToUnderscored($str) {
        $str = lcfirst($str);
        return preg_replace_callback(
            '/([A-Z])/',
            function ($str) {
                return "_" . strtolower($str[1]);
            },
            $str
        );
    }
static public function camelcasedToUnderscored ( $ str ) { $ str = lcfirst ( $ str ) ; return preg_replace_callback ( '/([A-Z])/' , function ( $ str ) { return "_" . strtolower ( $ str [ 1 ] ) ; } , $ str ) ; }
Converts 'SnoopDoggyDog' to 'snoop_doggy_dog'

@param string $str
@return string
Converts SnoopDoggyDog to snoop_doggy_dog