Passed
Push — master ( 478a0c...9f2f7c )
by Zlatin
01:26
created

Request   A

Complexity

Total Complexity 3

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 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 15 3
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 = [], $body = 'php://temp', $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 11
        } else if (is_resource($body)) {
30
            $this->body = (new Factory\StreamFactory())->createStreamFromResource($body);
31
        } else {
32 10
            $this->body = (new Factory\StreamFactory())->createStreamFromFile($body, "r+");
33
        }
34
35 12
        $this->headers = $headers;
36 12
        $this->protocolVersion = $protocolVersion;
37 12
    }
38
}
39