Conditions | 6 |
Paths | 18 |
Total Lines | 25 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 14 |
CRAP Score | 6.6563 |
Changes | 0 |
1 | <?php |
||
22 | 22 | public function __construct($method, UriInterface $uri, array $headers = [], $body = 'php://temp', $protocolVersion = '1.1') |
|
23 | { |
||
24 | 22 | $this->method = $method; |
|
25 | 22 | $this->uri = new Uri($uri); |
|
26 | |||
27 | 22 | if ($body instanceof StreamInterface) { |
|
28 | 2 | $this->body = $body; |
|
29 | 21 | } else if (is_resource($body)) { |
|
30 | $this->body = (new Factory\StreamFactory())->createStreamFromResource($body); |
||
31 | } else { |
||
32 | 20 | $this->body = (new Factory\StreamFactory())->createStreamFromFile($body, "wb+"); |
|
33 | } |
||
34 | |||
35 | 22 | foreach ($headers AS $header => $value) { |
|
36 | $normalize = strtolower($value); |
||
37 | $this->headersName[$header] = $normalize; |
||
38 | $this->headers[$normalize] = $value; |
||
39 | 11 | } |
|
40 | |||
41 | 22 | if (!$this->hasHeader('host')) { |
|
42 | 22 | $this->headersName['host'] = 'Host'; |
|
43 | 22 | $this->headers['Host'] = [!empty($this->uri->getHost()) ? $this->uri->getHost() : 'localhost']; |
|
44 | 11 | } |
|
45 | |||
46 | 22 | $this->protocolVersion = $protocolVersion; |
|
47 | 22 | } |
|
49 |