$value ) { if( ! in_array( $key, $ignoreKeys ) ){ $key = Str::camelize( $key, $separator ); } if( $recursive && is_array( $value ) ){ $value = self::camelizeKeys( $value ); } $result[ $key ] = $value; } return $result; } /** * Merges the defined arguments into defaults array. * * @param array|object $args Value to merge with $defaults. * @param array $defaults Array that serves as the defaults. * * @return array */ public static function merge( $args, $defaults = [] ) { if ( is_object( $args ) ) { $args = get_object_vars( $args ); } if ( is_array( $defaults ) && $defaults ) { return array_merge( $defaults, $args ); } return $args; } /** * Applies the callback to the elements of the given arrays recursively * * @param array $array * @param $callback */ public static function mapDeep( $array, $callback ){ if ( ! empty( $array ) ) { foreach ( $array as $index => $value ) { call_user_func( $callback, $value, $index ); if ( is_array( $value ) ) { static::mapDeep( $value, $callback ); } } } } /** * Searches the array for a given key and returns the first corresponding value if successful * * @param $haystack * @param $needle * * @return mixed|null */ public static function searchKeyDeep( $haystack, $needle ){ $iterator = new RecursiveArrayIterator( $haystack ); $recursive = new RecursiveIteratorIterator( $iterator, RecursiveIteratorIterator::SELF_FIRST ); foreach ( $recursive as $key => $value ) { if ( $key === $needle ) { return $value; } } return null; } }