Ouzo\Utilities\Strings::camelCaseToUnderscore PHP Метод

camelCaseToUnderscore() публичный статический Метод

Example: $string = 'LannistersAlwaysPayTheirDebts'; $underscored = Strings::camelCaseToUnderscore($string); Result: lannisters_always_pay_their_debts
public static camelCaseToUnderscore ( string $string ) : string
$string string
Результат string
    public static function camelCaseToUnderscore($string)
    {
        return mb_strtolower(preg_replace('/([[:lower:]])([[:upper:]])/u', '$1_$2', $string));
    }

Usage Example

 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);
         });
     }
 }
All Usage Examples Of Ouzo\Utilities\Strings::camelCaseToUnderscore