src/message/Request.php
public static function createFromString($Line)
    {
        // explode the string into lines.
        $lines = explode("\n", $Line);

        // extract the method and uri
        list( $method, $uri ) = explode(' ', array_shift($lines));

        $headers = [];

        foreach ($lines as $line) {
            // clean the line
            $line = trim($line);

            if (strpos($line, ': ') !== false) {
                list( $key, $value ) = explode(': ', $line);
                $headers[$key] = $value;
            }
        }
        
        $reqBody = new \Sofi\HTTP\RequestBody();
        $headers = \Sofi\HTTP\Headers::createFromArray($headers);
        $cookies = \Sofi\HTTP\Cookies::parseHeader($headers->get('cookie'));
        
        return new static($method, new \Sofi\HTTP\message\Uri($uri), $headers, $cookies, $_SERVER, $reqBody);
    }
public static function createFromString($Line)
    {
        // explode the string into lines.
        $lines = explode("\n", $Line);

        // extract the method and uri
        list( $method, $uri ) = explode(' ', array_shift($lines));

        $headers = [];

        foreach ($lines as $line) {
            // clean the line
            $line = trim($line);

            if (strpos($line, ': ') !== false) {
                list( $key, $value ) = explode(': ', $line);
                $headers[$key] = $value;
            }
        }
        
        $reqBody = new \Sofi\HTTP\RequestBody();
        $headers = \Sofi\HTTP\Headers::createFromArray($headers);
        $cookies = \Sofi\HTTP\Cookies::parseHeader($headers->get('cookie'));
        
        return new static($method, new \Sofi\HTTP\message\Uri($uri), $headers, $cookies, $_SERVER, $reqBody);
    }
public static function createFromString ( $ Line ) { // explode the string into lines. $ lines = explode ( "\n" , $ Line ) ; // extract the method and uri list ( $ method , $ uri ) = explode ( ' ' , array_shift ( $ lines ) ) ; $ headers = [ ] ; foreach ( $ lines as $ line ) { // clean the line $ line = trim ( $ line ) ; if ( strpos ( $ line , ': ' ) !== false ) { list ( $ key , $ value ) = explode ( ': ' , $ line ) ; $ headers [ $ key ] = $ value ; } } $ reqBody = new \ Sofi \ HTTP \ RequestBody ( ) ; $ headers = \ Sofi \ HTTP \ Headers :: createFromArray ( $ headers ) ; $ cookies = \ Sofi \ HTTP \ Cookies :: parseHeader ( $ headers -> get ( 'cookie' ) ) ; return new static ( $ method , new \ Sofi \ HTTP \ message \ Uri ( $ uri ) , $ headers , $ cookies , $ _SERVER , $ reqBody ) ; }
Create new headers collection with data extracted from string

@param string $Line

@return self
Create new headers collection with data extracted from string