Completed
Push — master ( d612da...6cfb36 )
by Jean-Baptiste
01:48
created

Guzzle6::setBaseUri()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
nc 1
cc 1
eloc 2
nop 1
1
<?php
2
3
namespace CanalTP\AbstractGuzzle\Version;
4
5
use GuzzleHttp\Psr7\Request;
6
use GuzzleHttp\Client;
7
use CanalTP\AbstractGuzzle\Guzzle;
8
9
class Guzzle6 extends Guzzle
10
{
11
    /**
12
     * @var Client
13
     */
14
    private $client;
15
16
    /**
17
     * {@InheritDoc}
18
     */
19 View Code Duplication
    public function __construct($baseUri, $options = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
20
    {
21
        $this->defaultOptions = array_merge([
22
            'base_uri' => $baseUri,
23
            'http_errors' => false
24
        ], $options);
25
26
        $this->client = new Client($this->defaultOptions);
27
    }
28
29
    public function setBaseUri($baseUri)
30
    {
31
        $this->setDefaultOptions(array_merge($this->defaultOptions, ['base_uri' => $baseUri]));
32
    }
33
34
    public function getBaseUri()
35
    {
36
        return $this->client->getConfig('base_uri');
37
    }
38
39
    public function setDefaultOptions($options = [])
40
    {
41
        $this->__construct($this->getBaseUri(), $options);
42
    }
43
44
    public function getDefaultOptions()
45
    {
46
        return $this->client->getConfig();
47
    }
48
49
    /**
50
     * @return Client
51
     */
52
    public function getClient()
53
    {
54
        return $this->client;
55
    }
56
57
    /**
58
     * @param Client $client
59
     *
60
     * @return self
61
     */
62
    public function setClient(Client $client)
63
    {
64
        $this->client = $client;
65
66
        return $this;
67
    }
68
69
    /**
70
     * {@InheritDoc}
71
     */
72
    public function send(Request $request)
73
    {
74
        return $this->client->send($request);
75
    }
76
}
77