Code Duplication    Length = 19-21 lines in 2 locations

src/Request.php 1 location

@@ 25-43 (lines=19) @@
22
     * @param string|resource|StreamInterface|null $body Request body
23
     * @param string $version Protocol version
24
     */
25
    public function __construct(string $method, $uri, array $headers = [], $body = null, string $version = '1.1')
26
    {
27
        if (!($uri instanceof UriInterface)) {
28
            $uri = new Uri($uri);
29
        }
30
31
        $this->method = $method;
32
        $this->uri = $uri;
33
        $this->setHeaders($headers);
34
        $this->protocol = $version;
35
36
        if (!$this->hasHeader('Host')) {
37
            $this->updateHostFromUri();
38
        }
39
40
        // If we got no body, defer initialization of the stream until Request::getBody()
41
        if ('' !== $body && null !== $body) {
42
            $this->stream = Stream::create($body);
43
        }
44
    }
45
}
46

src/ServerRequest.php 1 location

@@ 45-65 (lines=21) @@
42
     * @param string $version Protocol version
43
     * @param array $serverParams Typically the $_SERVER superglobal
44
     */
45
    public function __construct(string $method, $uri, array $headers = [], $body = null, string $version = '1.1', array $serverParams = [])
46
    {
47
        $this->serverParams = $serverParams;
48
49
        if (!($uri instanceof UriInterface)) {
50
            $uri = new Uri($uri);
51
        }
52
53
        $this->method = $method;
54
        $this->uri = $uri;
55
        $this->setHeaders($headers);
56
        $this->protocol = $version;
57
58
        if (!$this->hasHeader('Host')) {
59
            $this->updateHostFromUri();
60
        }
61
62
        // If we got no body, defer initialization of the stream until ServerRequest::getBody()
63
        if ('' !== $body && null !== $body) {
64
            $this->stream = Stream::create($body);
65
        }
66
    }
67
68
    public function getServerParams(): array