Completed
Pull Request — master (#16)
by Alessandro
06:12
created

Guzzle6Transport   A

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
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Fazland\SkebbyRestClient\Transport;
6
7
use GuzzleHttp\Client;
8
use GuzzleHttp\ClientInterface;
9
use GuzzleHttp\Psr7\Request;
10
11
/**
12
 * Guzzle6 Transport.
13
 */
14
class Guzzle6Transport implements TransportInterface
15
{
16
    private ClientInterface $client;
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_STRING, expecting T_FUNCTION or T_CONST
Loading history...
17
18
    public function __construct(?ClientInterface $client = null)
19
    {
20
        $this->client = $client ?: new Client();
21
    }
22
23
    public function executeRequest(string $uri, string $body): string
24
    {
25
        $request = new Request('POST', $uri, ['Content-Type' => 'application/x-www-form-urlencoded'], $body);
26 1
        $response = $this->client->send($request);
27
28 1
        return (string) $response->getBody();
29 1
    }
30
}
31