Completed
Push — master ( 66f0fe...d9d814 )
by Alessandro
06:28
created

HttpClientTransport   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 40%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 31
ccs 4
cts 10
cp 0.4
rs 10
c 1
b 0
f 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A executeRequest() 0 9 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, [
32
            'Content-Type' => 'application/x-www-form-urlencoded',
33
        ], $body);
34
        $response = $this->client->sendRequest($request);
35
36
        return (string) $response->getBody();
37
    }
38
}
39