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

Guzzle6Transport::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 0
Metric Value
dl 0
loc 9
ccs 0
cts 6
cp 0
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 2
crap 2
1
<?php
2
3
namespace Fazland\SkebbyRestClient\Transport;
4
5
use GuzzleHttp\Client;
6
use GuzzleHttp\Psr7\Request;
7
8
class Guzzle6Transport implements TransportInterface
9
{
10
    /**
11
     * @var Client
12
     */
13
    private $client;
14
15 1
    public function __construct(Client $client = null)
16
    {
17 1
        $this->client = $client ?: new Client();
18 1
    }
19
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function executeRequest($uri, $body)
24
    {
25
        $request = new Request('POST', $uri, [
26
            'Content-Type' => 'application/x-www-form-urlencoded',
27
        ], $body);
28
        $response = $this->client->send($request);
29
30
        return (string) $response->getBody();
31
    }
32
}
33