| Conditions | 5 |
| Paths | 8 |
| Total Lines | 20 |
| Lines | 19 |
| Ratio | 95 % |
| Tests | 12 |
| CRAP Score | 5 |
| Changes | 0 | ||
| 1 | <?php |
||
| 25 | 73 | View Code Duplication | public function __construct(string $method, $uri, array $headers = [], $body = null, string $version = '1.1') |
| 26 | { |
||
| 27 | 73 | if (!($uri instanceof UriInterface)) { |
|
| 28 | 71 | $uri = new Uri($uri); |
|
| 29 | } |
||
| 30 | |||
| 31 | 72 | $this->method = $method; |
|
| 32 | 72 | $this->uri = $uri; |
|
| 33 | 72 | $this->setHeaders($headers); |
|
| 34 | 72 | $this->protocol = $version; |
|
| 35 | |||
| 36 | 72 | if (!$this->hasHeader('Host')) { |
|
| 37 | 71 | $this->updateHostFromUri(); |
|
| 38 | } |
||
| 39 | |||
| 40 | // If we got no body, defer initialization of the stream until Request::getBody() |
||
| 41 | 72 | if ('' !== $body && null !== $body) { |
|
| 42 | 4 | $this->stream = Stream::create($body); |
|
| 43 | } |
||
| 44 | 72 | } |
|
| 45 | } |
||
| 46 |