CachedResponse   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 17
c 1
b 0
f 0
dl 0
loc 25
ccs 14
cts 14
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getResponse() 0 8 1
1
<?php
2
3
namespace hamburgscleanest\GuzzleAdvancedThrottle\Cache;
4
5
use GuzzleHttp\Psr7\Response;
6
use Psr\Http\Message\ResponseInterface;
7
8
class CachedResponse
9
{
10
    private array $_headers;
11
    private string $_body;
12
    private string $_protocol;
13
    private int $_statusCode;
14
    private string $_reason;
15
16 14
    public function __construct(ResponseInterface $response)
17
    {
18 14
        $this->_headers = $response->getHeaders();
19 14
        $this->_body = (string) $response->getBody();
20 14
        $this->_protocol = $response->getProtocolVersion();
21 14
        $this->_statusCode = $response->getStatusCode();
22 14
        $this->_reason = $response->getReasonPhrase();
23 14
    }
24
25 11
    public function getResponse(): Response
26
    {
27 11
        return new Response(
28 11
            $this->_statusCode,
29 11
            $this->_headers,
30 11
            $this->_body,
31 11
            $this->_protocol,
32 11
            $this->_reason
33
        );
34
    }
35
}
36