Completed
Pull Request — master (#76)
by Thibaud
02:50
created

GuzzleHttpClient   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
c 2
b 0
f 0
lcom 0
cbo 2
dl 0
loc 60
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 8 1
A __construct() 0 5 1
A getEndpoint() 0 4 1
A call() 0 10 1
1
<?php
2
3
/*
4
 * This file is part of Phraseanet-PHP-SDK.
5
 *
6
 * (c) Alchemy <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace PhraseanetSDK\Http\GuzzleHttp;
13
14
use GuzzleHttp\ClientInterface;
15
use PhraseanetSDK\Http\Client;
16
use PhraseanetSDK\Http\Endpoint;
17
18
class GuzzleHttpClient implements Client
19
{
20
21
    public static function create(Endpoint $endpoint)
22
    {
23
        $client = new \GuzzleHttp\Client([
24
            'base_url' => $endpoint->getUrl()
25
        ]);
26
27
        return new self($client, $endpoint);
28
    }
29
30
    /**
31
     * @var \GuzzleHttp\Client
32
     */
33
    private $client;
34
35
    /**
36
     * @var Endpoint
37
     */
38
    private $endpoint;
39
40
    /**
41
     * @param ClientInterface $client
42
     * @param Endpoint $endpoint
43
     */
44
    public function __construct(ClientInterface $client, Endpoint $endpoint)
45
    {
46
        $this->client = $client;
0 ignored issues
show
Documentation Bug introduced by
$client is of type object<GuzzleHttp\ClientInterface>, but the property $client was declared to be of type object<GuzzleHttp\Client>. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
47
        $this->endpoint = $endpoint;
48
    }
49
50
    /**
51
     * @return Endpoint
52
     */
53
    public function getEndpoint()
54
    {
55
        return $this->endpoint;
56
    }
57
58
    /**
59
     * @param string $method
60
     * @param string $path
61
     * @param array $query
62
     * @param array $postFields
63
     * @param array $files
64
     * @param array $headers
65
     * @return string
66
     */
67
    public function call(
68
        $method,
69
        $path,
70
        array $query = array(),
71
        array $postFields = array(),
72
        array $files = array(),
73
        array $headers = array()
74
    ) {
75
76
    }
77
}
78