GuzzleClient::init()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
3
namespace whm\Smoke\Http;
4
5
use phm\HttpWebdriverClient\Http\Client\Guzzle\GuzzleClient as phmGuzzleClient;
6
use phm\HttpWebdriverClient\Http\Client\Decorator\FileCacheDecorator;
7
use phm\HttpWebdriverClient\Http\Client\HttpClient;
8
use Psr\Http\Message\RequestInterface;
9
10
class GuzzleClient implements HttpClient
11
{
12
    /**
13
     * @var phmGuzzleClient
14
     */
15
    private $guzzleClient;
16
17
    /**
18
     * @param bool $nocache
19
     * @param integer $clientTimeout
20
     * @throws \Exception
21
     */
22
    public function init($nocache = true, $clientTimeout = 20000)
23
    {
24
        $timeoutInSeconds = (int)($clientTimeout / 1000);
25
26
        if ($nocache) {
27
            $this->guzzleClient = new phmGuzzleClient(null, $timeoutInSeconds);
28
        } else {
29
            $guzzleClient = new phmGuzzleClient(null, $timeoutInSeconds);
30
            $this->guzzleClient = new FileCacheDecorator($guzzleClient);
0 ignored issues
show
Documentation Bug introduced by
It seems like new \phm\HttpWebdriverCl...ecorator($guzzleClient) of type object<phm\HttpWebdriver...tor\FileCacheDecorator> is incompatible with the declared type object<phm\HttpWebdriver...nt\Guzzle\GuzzleClient> of property $guzzleClient.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
31
        }
32
    }
33
34
    public function sendRequest(RequestInterface $request)
35
    {
36
        return $this->guzzleClient->sendRequest($request);
37
    }
38
39
    public function sendRequests(array $requests)
40
    {
41
        return $this->guzzleClient->sendRequests($requests);
42
    }
43
44
    public function getClientType()
45
    {
46
        return $this->guzzleClient->getClientType();
47
    }
48
49
    public function close()
50
    {
51
52
    }
53
54
    public function setOption($key, $value)
55
    {
56
        $this->guzzleClient->setOption($key, $value);
57
    }
58
}
59