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

HttpClientTransport::executeRequest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 9
ccs 0
cts 6
cp 0
rs 9.6666
c 1
b 0
f 1
cc 1
eloc 6
nc 1
nop 2
crap 2
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