Braintree\Util::camelCaseToDelimiter PHP Метод

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

find capitals and convert to delimiter + lowercase
public static camelCaseToDelimiter ( string $string, null | string $delimiter = '-' ) : string
$string string
$delimiter null | string
Результат string modified string
    public static function camelCaseToDelimiter($string, $delimiter = '-')
    {
        return strtolower(preg_replace('/([A-Z])/', "{$delimiter}\\1", $string));
    }

Usage Example

 private function _underscoreKeys($array)
 {
     foreach ($array as $key => $value) {
         $newKey = Util::camelCaseToDelimiter($key, '_');
         unset($array[$key]);
         if (is_array($value)) {
             $array[$newKey] = $this->_underscoreKeys($value);
         } else {
             $array[$newKey] = $value;
         }
     }
     return $array;
 }