private function parseStatusLine($headers): string {
        if (empty($headers)) {
            return '';
        }

        if (is_string($headers)) {
            if (preg_match_all('`(?:^|\n)(HTTP/[^\r]+)\r\n`', $headers, $matches)) {
                $firstLine = end($matches[1]);
            } else {
                $firstLine = trim(strstr($headers, "\r\n", true));
            }
        } else {
            $firstLine = (string)reset($headers);
        }

        // Test the status line.
        if (strpos($firstLine, 'HTTP/') === 0) {
            return $firstLine;
        }
        return '';
    }
private function parseStatusLine($headers): string {
        if (empty($headers)) {
            return '';
        }

        if (is_string($headers)) {
            if (preg_match_all('`(?:^|\n)(HTTP/[^\r]+)\r\n`', $headers, $matches)) {
                $firstLine = end($matches[1]);
            } else {
                $firstLine = trim(strstr($headers, "\r\n", true));
            }
        } else {
            $firstLine = (string)reset($headers);
        }

        // Test the status line.
        if (strpos($firstLine, 'HTTP/') === 0) {
            return $firstLine;
        }
        return '';
    }
private function parseStatusLine ( $ headers ) : string { if ( empty ( $ headers ) ) { return '' ; } if ( is_string ( $ headers ) ) { if ( preg_match_all ( '`(?:^|\n)(HTTP/[^\r]+)\r\n`' , $ headers , $ matches ) ) { $ firstLine = end ( $ matches [ 1 ] ) ; } else { $ firstLine = trim ( strstr ( $ headers , "\r\n" , true ) ) ; } } else { $ firstLine = ( string ) reset ( $ headers ) ; } // Test the status line. if ( strpos ( $ firstLine , 'HTTP/' ) === 0 ) { return $ firstLine ; } return '' ; }
Parse the status line from a header string or array.

@param string|array $headers Either a header string or a header array.
@return string Returns the status line or an empty string if the first line is not an HTTP status.
Parse the status line from a header string or array .