You are here

private static function Serializer::getRequestLine in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/zendframework/zend-diactoros/src/Request/Serializer.php \Zend\Diactoros\Request\Serializer::getRequestLine()

Retrieve the components of the request line.

Retrieves the first line of the stream and parses it, raising an exception if it does not follow specifications; if valid, returns a list with the method, target, and version, in that order.

Parameters

StreamInterface $stream:

Return value

array

1 call to Serializer::getRequestLine()
Serializer::fromStream in vendor/zendframework/zend-diactoros/src/Request/Serializer.php
Deserialize a request stream to a request instance.

File

vendor/zendframework/zend-diactoros/src/Request/Serializer.php, line 110

Class

Serializer
Serialize (cast to string) or deserialize (cast string to Request) messages.

Namespace

Zend\Diactoros\Request

Code

private static function getRequestLine(StreamInterface $stream) {
  $requestLine = self::getLine($stream);
  if (!preg_match('#^(?P<method>[!\\#$%&\'*+.^_`|~a-zA-Z0-9-]+) (?P<target>[^\\s]+) HTTP/(?P<version>[1-9]\\d*\\.\\d+)$#', $requestLine, $matches)) {
    throw new UnexpectedValueException('Invalid request line detected');
  }
  return [
    $matches['method'],
    $matches['target'],
    $matches['version'],
  ];
}