public static function fromHeader(string $string): array
    {
        $cookies = \explode(";", $string);
        $result = [];

        try {
            foreach ($cookies as $cookie) {
                $parts = \explode('=', $cookie, 2);

                if (2 !== \count($parts)) {
                    return [];
                }

                list($name, $value) = $parts;

                // We can safely trim quotes, as they're not allowed within cookie values
                $result[] = new self(\trim($name), \trim($value, " \t\""));
            }
        } catch (InvalidCookieException $e) {
            return [];
        }

        return $result;
    }
public static function fromHeader(string $string): array
    {
        $cookies = \explode(";", $string);
        $result = [];

        try {
            foreach ($cookies as $cookie) {
                $parts = \explode('=', $cookie, 2);

                if (2 !== \count($parts)) {
                    return [];
                }

                list($name, $value) = $parts;

                // We can safely trim quotes, as they're not allowed within cookie values
                $result[] = new self(\trim($name), \trim($value, " \t\""));
            }
        } catch (InvalidCookieException $e) {
            return [];
        }

        return $result;
    }
public static function fromHeader ( string $ string ) : array { $ cookies = \ explode ( ";" , $ string ) ; $ result = [ ] ; try { foreach ( $ cookies as $ cookie ) { $ parts = \ explode ( '=' , $ cookie , 2 ) ; if ( 2 !== \ count ( $ parts ) ) { return [ ] ; } list ( $ name , $ value ) = $ parts ; // We can safely trim quotes, as they're not allowed within cookie values $ result [ ] = new self ( \ trim ( $ name ) , \ trim ( $ value , " \t\"" ) ) ; } } catch ( InvalidCookieException $ e ) { return [ ] ; } return $ result ; }
Parses the cookies from a 'cookie' header.

Note: Parsing is aborted if there's an invalid value and no cookies are returned.

@param string $string Valid 'cookie' header line.

@return RequestCookie[]
Parses the cookies from a cookie header .