Failed Conditions
Push — master ( 2fcedf...efe7fa )
by Guillermo A.
01:42
created

GuzzleAdapter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A send() 0 4 1
A getClient() 0 12 2
1
<?php
2
3
namespace Guillermoandrae\Highrise\Http;
4
5
use GuzzleHttp\Client;
6
use GuzzleHttp\Psr7\Request;
7
8
class GuzzleAdapter extends AbstractAdapter
9
{
10
    public function getClient(): Client
11
    {
12
        if (!$this->client) {
13
            $this->setClient(new Client([
14
                'base_uri' => sprintf('https://%s.highrisehq.com', $this->getSubdomain()),
15
                'headers' => [
16
                    'User-Agent' => static::HEADER_DEFAULT_USER_AGENT,
17
                ],
18
                'auth' => [$this->getToken(), $this->getPassword()]
19
            ]));
20
        }
21
        return $this->client;
22
    }
23
24
    protected function send(string $method, string $uri, array $options = [])
25
    {
26
        $this->lastRequest = new Request($method, $uri);
27
        $this->lastResponse = $this->getClient()->send($this->lastRequest, $options);
28
    }
29
}
30