src/Api/Parser/AbstractRestParser.php
private function extractHeader(
        $name,
        Shape $shape,
        ResponseInterface $response,
        &$result
    ) {
        $value = $response->getHeaderLine($shape['locationName'] ?: $name);

        switch ($shape->getType()) {
            case 'float':
            case 'double':
                $value = (float) $value;
                break;
            case 'long':
                $value = (int) $value;
                break;
            case 'boolean':
                $value = filter_var($value, FILTER_VALIDATE_BOOLEAN);
                break;
            case 'blob':
                $value = base64_decode($value);
                break;
            case 'timestamp':
                try {
                    if (!empty($shape['timestampFormat'])
                        && $shape['timestampFormat'] === 'unixTimestamp') {
                        $value = DateTimeResult::fromEpoch($value);
                    }
                    $value = new DateTimeResult($value);
                    break;
                } catch (\Exception $e) {
                    // If the value cannot be parsed, then do not add it to the
                    // output structure.
                    return;
                }
            case 'string':
                if ($shape['jsonvalue']) {
                    $value = $this->parseJson(base64_decode($value), $response);
                }
                break;
        }

        $result[$name] = $value;
    }
private function extractHeader(
        $name,
        Shape $shape,
        ResponseInterface $response,
        &$result
    ) {
        $value = $response->getHeaderLine($shape['locationName'] ?: $name);

        switch ($shape->getType()) {
            case 'float':
            case 'double':
                $value = (float) $value;
                break;
            case 'long':
                $value = (int) $value;
                break;
            case 'boolean':
                $value = filter_var($value, FILTER_VALIDATE_BOOLEAN);
                break;
            case 'blob':
                $value = base64_decode($value);
                break;
            case 'timestamp':
                try {
                    if (!empty($shape['timestampFormat'])
                        && $shape['timestampFormat'] === 'unixTimestamp') {
                        $value = DateTimeResult::fromEpoch($value);
                    }
                    $value = new DateTimeResult($value);
                    break;
                } catch (\Exception $e) {
                    // If the value cannot be parsed, then do not add it to the
                    // output structure.
                    return;
                }
            case 'string':
                if ($shape['jsonvalue']) {
                    $value = $this->parseJson(base64_decode($value), $response);
                }
                break;
        }

        $result[$name] = $value;
    }
private function extractHeader ( $ name , Shape $ shape , ResponseInterface $ response , & $ result ) { $ value = $ response -> getHeaderLine ( $ shape [ 'locationName' ] ? : $ name ) ; switch ( $ shape -> getType ( ) ) { case 'float' : case 'double' : $ value = ( float ) $ value ; break ; case 'long' : $ value = ( int ) $ value ; break ; case 'boolean' : $ value = filter_var ( $ value , FILTER_VALIDATE_BOOLEAN ) ; break ; case 'blob' : $ value = base64_decode ( $ value ) ; break ; case 'timestamp' : try { if ( ! empty ( $ shape [ 'timestampFormat' ] ) && $ shape [ 'timestampFormat' ] === 'unixTimestamp' ) { $ value = DateTimeResult :: fromEpoch ( $ value ) ; } $ value = new DateTimeResult ( $ value ) ; break ; } catch ( \ Exception $ e ) { // If the value cannot be parsed, then do not add it to the // output structure. return ; } case 'string' : if ( $ shape [ 'jsonvalue' ] ) { $ value = $ this -> parseJson ( base64_decode ( $ value ) , $ response ) ; } break ; } $ result [ $ name ] = $ value ; }
Extract a single header from the response into the result.
Extract a single header from the response into the result .