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

HttpClient::send()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
crap 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