Example:
$string = 'LannistersAlwaysPayTheirDebts';
$underscored = Strings::camelCaseToUnderscore($string);
Result:
lannisters_always_pay_their_debts
public static camelCaseToUnderscore ( string $string ) : string | ||
$string | string | |
return | string |
public function parse() { if (preg_match('/^findBy([a-zA-Z]\\w*)$/', $this->method, $names)) { $names = explode('And', $names[1]); $this->names = Arrays::map($names, function ($name) { return Strings::camelCaseToUnderscore($name); }); } }
/** * @test */ public function shouldConvertCamelCaseWithUnderscoreToUnderscore() { //given $string = 'LannistersAlwaysPay_Their_Debts'; //when $underscored = Strings::camelCaseToUnderscore($string); //then $this->assertEquals('lannisters_always_pay_their_debts', $underscored); }
public function getTab() { $noController = Strings::remove(get_called_class(), 'Controller'); $noSlashes = Strings::remove($noController, '\\'); return Strings::camelCaseToUnderscore($noSlashes); }
private function _objectName() { return Strings::camelCaseToUnderscore($this->_object->getModelName()); }