public function renderRequest(RequestInterface $request)
    {
        $return  = '';
        $return .= sprintf("URL:     %s\n", $request->getUri());
        $return .= sprintf("METHOD:  %s\n", $request->getMethod());

        if ($request->getHeaders()) {
            $return .= 'HEADERS:';
        }

        $indent = false;
        foreach ($request->getHeaders() as $name => $values) {
            if ($indent) {
                $return .= str_repeat(' ', 8);
            }

            $return .= sprintf(" %s: %s\n", $name, implode(', ', $values));
            $indent  = true;
        }

        if ($body = (string) $request->getBody()) {
            $return .= 'BODY:    ';

            switch ($request->getHeaderLine('Content-Type')) {
                case 'application/json':
                    $return .= json_encode(json_decode($body, true), JSON_PRETTY_PRINT);
                    break;
                default:
                    $return .= $body;
                    break;
            }

            $return .= "\n";
        }

        return $return;
    }
public function renderRequest(RequestInterface $request)
    {
        $return  = '';
        $return .= sprintf("URL:     %s\n", $request->getUri());
        $return .= sprintf("METHOD:  %s\n", $request->getMethod());

        if ($request->getHeaders()) {
            $return .= 'HEADERS:';
        }

        $indent = false;
        foreach ($request->getHeaders() as $name => $values) {
            if ($indent) {
                $return .= str_repeat(' ', 8);
            }

            $return .= sprintf(" %s: %s\n", $name, implode(', ', $values));
            $indent  = true;
        }

        if ($body = (string) $request->getBody()) {
            $return .= 'BODY:    ';

            switch ($request->getHeaderLine('Content-Type')) {
                case 'application/json':
                    $return .= json_encode(json_decode($body, true), JSON_PRETTY_PRINT);
                    break;
                default:
                    $return .= $body;
                    break;
            }

            $return .= "\n";
        }

        return $return;
    }
public function renderRequest ( RequestInterface $ request ) { $ return = '' ; $ return .= sprintf ( "URL:     %s\n" , $ request -> getUri ( ) ) ; $ return .= sprintf ( "METHOD:  %s\n" , $ request -> getMethod ( ) ) ; if ( $ request -> getHeaders ( ) ) { $ return .= 'HEADERS:' ; } $ indent = false ; foreach ( $ request -> getHeaders ( ) as $ name => $ values ) { if ( $ indent ) { $ return .= str_repeat ( ' ' , 8 ) ; } $ return .= sprintf ( " %s: %s\n" , $ name , implode ( ', ' , $ values ) ) ; $ indent = true ; } if ( $ body = ( string ) $ request -> getBody ( ) ) { $ return .= 'BODY:    ' ; switch ( $ request -> getHeaderLine ( 'Content-Type' ) ) { case 'application/json' : $ return .= json_encode ( json_decode ( $ body , true ) , JSON_PRETTY_PRINT ) ; break ; default : $ return .= $ body ; break ; } $ return .= "\n" ; } return $ return ; }
Render a PSR-7 request.

@param RequestInterface $request
@return string
Render a PSR - 7 request .