HttpClient   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
getLatLong() 0 1 ?
A __construct() 0 4 2
A get() 0 6 1
1
<?php
2
3
namespace Ptondereau\GoogleAddressConverter\Http;
4
5
use GuzzleHttp\Psr7\Request;
6
use Http\Client\HttpClient as Client;
7
use Http\Discovery\HttpClientDiscovery;
8
use Ptondereau\GoogleAddressConverter\Address;
9
10
abstract class HttpClient
11
{
12
    /**
13
     * @var Client Client HTTP.
14
     */
15
    protected $httpClient;
16
17
    /**
18
     * Client constructor.
19
     *
20
     * @param Client $httpClient
21
     */
22 9
    public function __construct(Client $httpClient = null)
23
    {
24 9
        $this->httpClient = $httpClient ?: HttpClientDiscovery::find();
25 9
    }
26
27
    /**
28
     * Send GET HTTP to a given endpoint.
29
     *
30
     * @param null|string $uri
31
     *
32
     * @return \Psr\Http\Message\StreamInterface
33
     */
34 6
    public function get($uri = null)
35
    {
36 6
        $request = new Request('GET', $uri);
37
38 6
        return $this->httpClient->sendRequest($request)->getBody();
39
    }
40
41
    abstract public function getLatLong(Address $address);
42
}
43