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

Guzzle6   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 68
Duplicated Lines 13.24 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 2
dl 9
loc 68
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 9 9 1
A setBaseUri() 0 4 1
A getBaseUri() 0 4 1
A setDefaultOptions() 0 4 1
A getDefaultOptions() 0 4 1
A getClient() 0 4 1
A setClient() 0 6 1
A send() 0 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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