private static function getStatusLine(StreamInterface $stream) { $line = self::getLine($stream); if (!preg_match('#^HTTP/(?P<version>[1-9]\\d*\\.\\d) (?P<status>[1-5]\\d{2})(\\s+(?P<reason>.+))?$#', $line, $matches)) { throw new UnexpectedValueException('No status line detected'); } return [$matches['version'], $matches['status'], isset($matches['reason']) ? $matches['reason'] : '']; }