Braintree\Util::delimiterToCamelCase PHP Method

delimiterToCamelCase() public static method

convert alpha-beta-gamma to alphaBetaGamma
public static delimiterToCamelCase ( string $string, null | string $delimiter = '[\-\_]' ) : string
$string string
$delimiter null | string
return string modified string
    public static function delimiterToCamelCase($string, $delimiter = '[\\-\\_]')
    {
        // php doesn't garbage collect functions created by create_function()
        // so use a static variable to avoid adding a new function to memory
        // every time this function is called.
        static $callback = null;
        if ($callback === null) {
            $callback = create_function('$matches', 'return strtoupper($matches[1]);');
        }
        return preg_replace_callback('/' . $delimiter . '(\\w)/', $callback, $string);
    }

Usage Example

Esempio n. 1
0
 /**
  * initializes instance properties from the keys/values of an array
  * @ignore
  * @access protected
  * @param array $attributes array of properties to set - single level
  * @return void
  */
 private function _initializeFromArray($attributes)
 {
     foreach ($attributes as $name => $value) {
         $varName = "_{$name}";
         $this->{$varName} = Util::delimiterToCamelCase($value, '_');
     }
 }
All Usage Examples Of Braintree\Util::delimiterToCamelCase