Completed
Push — master ( 955d05...19c28e )
by David
03:37
created

EmulatedHttpAsyncClient   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 80%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 17
ccs 4
cts 5
cp 0.8
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 3
1
<?php
2
3
namespace Http\Client\Common;
4
5
use Http\Client\HttpAsyncClient;
6
use Http\Client\HttpClient;
7
use Psr\Http\Client\ClientInterface;
8
9
/**
10
 * Emulates an async HTTP client.
11
 *
12
 * This should be replaced by an anonymous class in PHP 7.
13
 *
14
 * @author Márk Sági-Kazár <[email protected]>
15
 */
16
class EmulatedHttpAsyncClient implements HttpClient, HttpAsyncClient
17
{
18
    use HttpAsyncClientEmulator;
19
    use HttpClientDecorator;
20
21
    /**
22
     * @param HttpClient|ClientInterface $httpClient
23
     */
24 35
    public function __construct($httpClient)
25
    {
26 35
        if (!($httpClient instanceof HttpClient) && !($httpClient instanceof ClientInterface)) {
0 ignored issues
show
Bug introduced by
The class Psr\Http\Client\ClientInterface does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
27
            throw new \LogicException('Client must be an instance of Http\\Client\\HttpClient or Psr\\Http\\Client\\ClientInterface');
28
        }
29
30 35
        $this->httpClient = $httpClient;
31 35
    }
32
}
33