You are here

private static function Braintree_Util::_flattenUserKeys in Commerce Braintree 7

1 call to Braintree_Util::_flattenUserKeys()
Braintree_Util::verifyKeys in braintree_php/lib/Braintree/Util.php
verify user request structure

File

braintree_php/lib/Braintree/Util.php, line 229

Class

Braintree_Util
Braintree Utility methods

Code

private static function _flattenUserKeys($keys, $namespace = null) {
  $flattenedArray = array();
  foreach ($keys as $key => $value) {
    $fullKey = empty($namespace) ? $key : $namespace;
    if (!is_numeric($key) && $namespace != null) {
      $fullKey .= '[' . $key . ']';
    }
    if (is_numeric($key) && is_string($value)) {
      $fullKey .= '[' . $value . ']';
    }
    if (is_array($value)) {
      $more = self::_flattenUserKeys($value, $fullKey);
      $flattenedArray = array_merge($flattenedArray, $more);
    }
    else {
      $flattenedArray[] = $fullKey;
    }
  }
  sort($flattenedArray);
  return $flattenedArray;
}