Completed
Push — develop ( de0fb5...78995e )
by Risan Bagja
01:33
created

HttpClient   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 50
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 2
A getGuzzle() 0 4 1
A request() 0 4 1
A send() 0 8 1
A post() 0 4 1
1
<?php
2
3
namespace Risan\OAuth1;
4
5
use GuzzleHttp\Client as Guzzle;
6
use Risan\OAuth1\Request\RequestInterface;
7
8
class HttpClient implements HttpClientInterface
9
{
10
    protected $guzzle;
11
12
    /**
13
     * Create an instance of HttpClient.
14
     */
15 5
    public function __construct(Guzzle $guzzle = null)
16
    {
17 5
        $this->guzzle = $guzzle === null ? new Guzzle : $guzzle;
18 5
    }
19
20
    /**
21
     * Get Guzzle client instance.
22
     *
23
     * @return \GuzzleHttp\Client
24
     */
25 1
    public function getGuzzle()
26
    {
27 1
        return $this->guzzle;
28
    }
29
30
    /**
31
     * {@inheritDoc}
32
     */
33 1
    public function request($method, $uri, array $options = [])
34
    {
35 1
        return $this->guzzle->request($method, $uri, $options);
36
    }
37
38
    /**
39
     * {@inheritDoc}
40
     */
41 1
    public function send(RequestInterface $request)
42
    {
43 1
        return $this->request(
44 1
            $request->getMethod(),
45 1
            $request->getUri(),
46 1
            $request->getOptions()
47
        );
48
    }
49
50
    /**
51
     * {@inheritDoc}
52
     */
53 1
    public function post($uri, array $options = [])
54
    {
55 1
        return $this->request('POST', $uri, $options);
56
    }
57
}
58