Completed
Push — master ( 5f5045...66f0fe )
by Alessandro
07:07
created

HttpClientTransport   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 29
ccs 4
cts 8
cp 0.5
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A executeRequest() 0 7 1
1
<?php
2
3
namespace Fazland\SkebbyRestClient\Transport;
4
5
use Http\Client\HttpClient;
6
use Http\Message\MessageFactory;
7
8
class HttpClientTransport implements TransportInterface
9
{
10
    /**
11
     * @var HttpClient
12
     */
13
    private $client;
14
15
    /**
16
     * @var MessageFactory
17
     */
18
    private $messageFactory;
19
20 1
    public function __construct(HttpClient $client, MessageFactory $messageFactory)
21
    {
22 1
        $this->client = $client;
23 1
        $this->messageFactory = $messageFactory;
24 1
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function executeRequest($uri, $body)
30
    {
31
        $request = $this->messageFactory->createRequest('POST', $uri, [], $body);
32
        $response = $this->client->sendRequest($request);
33
34
        return (string) $response->getBody();
35
    }
36
}
37