Passed
Push — master ( 37358f...e9906c )
by Zlatin
01:33
created

Request   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 81.82%

Importance

Changes 0
Metric Value
dl 0
loc 29
ccs 9
cts 11
cp 0.8182
rs 10
c 0
b 0
f 0
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 15 4
1
<?php
2
namespace DevOp\Core\Http;
3
4
use Psr\Http\Message\UriInterface;
5
use Psr\Http\Message\StreamInterface;
6
use Psr\Http\Message\RequestInterface;
7
8
class Request implements RequestInterface
9
{
10
11
    use Traits\MessageTrait;
12
    use Traits\RequestTrait;
13
14
    /**
15
     * 
16
     * @param string $method
17
     * @param string|UriInterface $uri
18
     * @param array $headers
19
     * @param string|resource|StreamInterface $body
20
     * @param string $protocolVersion
21
     */
22 12
    public function __construct($method, UriInterface $uri, array $headers = [], StreamInterface $body = null, $protocolVersion = '1.1')
23
    {
24 12
        $this->method = $method;
25 12
        $this->uri = new Uri($uri);
26
        
27 12
        if ($body instanceof StreamInterface) {
28 2
            $this->body = $body;
29 10
        } else if (is_resource($body)) {
0 ignored issues
show
introduced by
The condition is_resource($body) can never be true.
Loading history...
30
            $this->body = (new Factory\StreamFactory())->createStreamFromFile($body, "r+");
31 10
        } else if (is_string($body)) {
0 ignored issues
show
introduced by
The condition is_string($body) can never be true.
Loading history...
32
            $this->body = (new Factory\StreamFactory())->createStream($body);
33
        }
34
        
35 12
        $this->headers = $headers;
36 12
        $this->protocolVersion = $protocolVersion;
37 12
    }
38
}
39