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

HttpClientTransport::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
crap 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