Zend\Diactoros\RequestTrait::initialize PHP Method

initialize() private method

Used by constructors.
private initialize ( null | string | Psr\Http\Message\UriInterface $uri = null, null | string $method = null, string | resource | Psr\Http\Message\StreamInterface $body = 'php://memory', array $headers = [] )
$uri null | string | Psr\Http\Message\UriInterface URI for the request, if any.
$method null | string HTTP method for the request, if any.
$body string | resource | Psr\Http\Message\StreamInterface Message body, if any.
$headers array Headers for the message, if any.
    private function initialize($uri = null, $method = null, $body = 'php://memory', array $headers = [])
    {
        $this->validateMethod($method);
        $this->method = $method ?: '';
        $this->uri = $this->createUri($uri);
        $this->stream = $this->getStream($body, 'wb+');
        list($this->headerNames, $headers) = $this->filterHeaders($headers);
        $this->assertHeaders($headers);
        $this->headers = $headers;
        // per PSR-7: attempt to set the Host header from a provided URI if no
        // Host header is provided
        if (!$this->hasHeader('Host') && $this->uri->getHost()) {
            $this->headerNames['host'] = 'Host';
            $this->headers['Host'] = [$this->getHostFromUri()];
        }
    }