vendor/nyholm/psr7/src/Request.php line 15

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Nyholm\Psr7;
  4. use Psr\Http\Message\{RequestInterfaceStreamInterfaceUriInterface};
  5. /**
  6.  * @author Tobias Nyholm <tobias.nyholm@gmail.com>
  7.  * @author Martijn van der Ven <martijn@vanderven.se>
  8.  *
  9.  * @final This class should never be extended. See https://github.com/Nyholm/psr7/blob/master/doc/final.md
  10.  */
  11. class Request implements RequestInterface
  12. {
  13.     use MessageTrait;
  14.     use RequestTrait;
  15.     /**
  16.      * @param string $method HTTP method
  17.      * @param string|UriInterface $uri URI
  18.      * @param array $headers Request headers
  19.      * @param string|resource|StreamInterface|null $body Request body
  20.      * @param string $version Protocol version
  21.      */
  22.     public function __construct(string $method$uri, array $headers = [], $body nullstring $version '1.1')
  23.     {
  24.         if (!($uri instanceof UriInterface)) {
  25.             $uri = new Uri($uri);
  26.         }
  27.         $this->method $method;
  28.         $this->uri $uri;
  29.         $this->setHeaders($headers);
  30.         $this->protocol $version;
  31.         if (!$this->hasHeader('Host')) {
  32.             $this->updateHostFromUri();
  33.         }
  34.         // If we got no body, defer initialization of the stream until Request::getBody()
  35.         if ('' !== $body && null !== $body) {
  36.             $this->stream Stream::create($body);
  37.         }
  38.     }
  39. }