public static function mapKey($origin, $map = [])
    {
        $result = is_array($origin) ? [] : new \stdClass();

        foreach ((array) $origin as $key => $val) {
            $newKey = self::getValue($map, $key);

            if ($newKey) {
                self::setValue($result, $newKey, $val);
            } else {
                self::setValue($result, $key, $val);
            }
        }

        return $result;
    }
public static function mapKey($origin, $map = [])
    {
        $result = is_array($origin) ? [] : new \stdClass();

        foreach ((array) $origin as $key => $val) {
            $newKey = self::getValue($map, $key);

            if ($newKey) {
                self::setValue($result, $newKey, $val);
            } else {
                self::setValue($result, $key, $val);
            }
        }

        return $result;
    }
public static function mapKey ( $ origin , $ map = [ ] ) { $ result = is_array ( $ origin ) ? [ ] : new \ stdClass ( ) ; foreach ( ( array ) $ origin as $ key => $ val ) { $ newKey = self :: getValue ( $ map , $ key ) ; if ( $ newKey ) { self :: setValue ( $ result , $ newKey , $ val ) ; } else { self :: setValue ( $ result , $ key , $ val ) ; } } return $ result ; }
Convert an Array or Object keys to new name by an array index.

@param   mixed $origin Array or Object to convert.
@param   mixed $map    Array or Object index for convert.

@return  mixed Mapped array or object.
Convert an Array or Object keys to new name by an array index .