Guzzle6Transport   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 33.33%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 30
ccs 3
cts 9
cp 0.3333
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 2
A executeRequest() 0 9 1
1
<?php declare(strict_types=1);
2
3
namespace Fazland\SkebbyRestClient\Transport;
4
5
use GuzzleHttp\Client;
6
use GuzzleHttp\ClientInterface;
7
use GuzzleHttp\Psr7\Request;
8
9
/**
10
 * Guzzle6 Transport.
11
 *
12
 * @author Alessandro Chitolina <[email protected]>
13
 */
14
class Guzzle6Transport implements TransportInterface
15
{
16
    /**
17
     * @var ClientInterface
18
     */
19
    private $client;
20
21
    /**
22
     * Guzzle6Transport constructor.
23
     *
24
     * @param ClientInterface|null $client
25
     */
26 1
    public function __construct(ClientInterface $client = null)
27
    {
28 1
        $this->client = $client ?: new Client();
29 1
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function executeRequest(string $uri, string $body): string
35
    {
36
        $request = new Request('POST', $uri, [
37
            'Content-Type' => 'application/x-www-form-urlencoded',
38
        ], $body);
39
        $response = $this->client->send($request);
40
41
        return (string) $response->getBody();
42
    }
43
}
44