Conditions | 5 |
Paths | 9 |
Total Lines | 20 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 16 |
CRAP Score | 5 |
Changes | 0 |
1 | <?php |
||
22 | 28 | public function __construct($method, UriInterface $uri, array $headers = [], $body, $protocolVersion = '1.1') |
|
23 | { |
||
24 | 28 | $this->method = $method; |
|
25 | 28 | $this->uri = $uri; |
|
26 | 28 | $this->body = $body; |
|
27 | |||
28 | 28 | foreach ($headers AS $header => $value) { |
|
29 | 2 | $this->headersName[strtolower($header)] = $header; |
|
30 | 2 | $this->headers[$header] = !is_array($value) ? [$value] : $value; |
|
31 | 14 | } |
|
32 | |||
33 | 28 | if (!$this->hasHeader('Host')) { |
|
34 | 28 | if (!$uri = $this->uri->getHost()) { |
|
35 | 24 | $uri = 'localhost'; |
|
36 | 12 | } |
|
37 | 28 | $this->headersName['host'] = 'Host'; |
|
38 | 28 | $this->headers['Host'] = [$uri]; |
|
39 | 14 | } |
|
40 | |||
41 | 28 | $this->protocolVersion = $protocolVersion; |
|
42 | 28 | } |
|
44 |