Conditions | 7 |
Paths | 27 |
Total Lines | 27 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Tests | 17 |
CRAP Score | 7.3387 |
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 | 22 | } 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 | $this->headersName[strtolower($header)] = $header; |
||
37 | $this->headers[$header] = !is_array($value) ? [$value] : $value; |
||
38 | 22 | } |
|
39 | |||
40 | 22 | if (!$this->hasHeader('Host')) { |
|
41 | 22 | if (null === $uri = $this->uri->getHost()) { |
|
|
|||
42 | 22 | $uri = 'localhost'; |
|
43 | 22 | } |
|
44 | 22 | $this->headersName['host'] = 'Host'; |
|
45 | 22 | $this->headers['Host'] = [$uri]; |
|
46 | 22 | } |
|
47 | |||
48 | 22 | $this->protocolVersion = $protocolVersion; |
|
49 | 22 | } |
|
51 |