Passed
Pull Request — master (#43)
by Baptiste
02:06
created

Client   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 25
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getResponse() 0 10 2
1
<?php declare(strict_types=1);
2
namespace Behapi\Http;
3
4
use RuntimeException;
5
6
use Psr\Http\Message\ResponseInterface;
7
8
use Http\Client\HttpClient;
9
use Http\Message\StreamFactory;
10
use Http\Message\MessageFactory;
11
12
use Behapi\HttpHistory\History as HttpHistory;
13
14
trait Client
15
{
16
    /** @var HttpClient */
17
    private $client;
18
19
    /** @var StreamFactory */
20
    private $streamFactory;
21
22
    /** @var MessageFactory */
23
    private $messageFactory;
24
25
    /** @var HttpHistory */
26
    private $history;
27
28
    public function getResponse(): ResponseInterface
29
    {
30
        $response = $this->history->getLastResponse();
31
32
        if (!$response instanceof ResponseInterface) {
33
            throw new RuntimeException('No response');
34
        }
35
36
        return $response;
37
    }
38
}
39