public static function createFromString(string $string) : Response
    {

        $lines = explode("\r\n", $string);
        list($httpVersion, $statusCode, $statusText) = explode(' ', array_shift($lines), 3);

        $headers = new Headers();

        foreach ($lines as $index => $line) {
            unset($lines[$index]);

            if($line !== ''){
                $headers->add(Header::createFromString($line));
            }else{
                // We are done with the header part
                break;
            }
        }

        return new Response(implode("\r\n", $lines), $statusCode, $headers);
    }
public static function createFromString(string $string) : Response
    {

        $lines = explode("\r\n", $string);
        list($httpVersion, $statusCode, $statusText) = explode(' ', array_shift($lines), 3);

        $headers = new Headers();

        foreach ($lines as $index => $line) {
            unset($lines[$index]);

            if($line !== ''){
                $headers->add(Header::createFromString($line));
            }else{
                // We are done with the header part
                break;
            }
        }

        return new Response(implode("\r\n", $lines), $statusCode, $headers);
    }
public static function createFromString ( string $ string ) : Response { $ lines = explode ( "\r\n" , $ string ) ; list ( $ httpVersion , $ statusCode , $ statusText ) = explode ( ' ' , array_shift ( $ lines ) , 3 ) ; $ headers = new Headers ( ) ; foreach ( $ lines as $ index => $ line ) { unset ( $ lines [ $ index ] ) ; if ( $ line !== '' ) { $ headers -> add ( Header :: createFromString ( $ line ) ) ; } else { // We are done with the header part break ; } } return new Response ( implode ( "\r\n" , $ lines ) , $ statusCode , $ headers ) ; }
Create a Response object from a string

@param string $string
@return Response
Create a Response object from a string