AbstractClient::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 2
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace IBM\Watson\Common;
6
7
use Http\Client\HttpClient;
8
use IBM\Watson\Common\Util\DiscoveryTrait;
9
10
/**
11
 * Abstract service client which all other service clients should extend from.
12
 */
13
abstract class AbstractClient
14
{
15
    use DiscoveryTrait;
16
17
    /**
18
     * @var \Http\Client\HttpClient|null
19
     */
20
    protected $httpClient;
21
22
    /**
23
     * @param \Http\Client\HttpClient|null $httpClient HTTP client to send requests.
24
     */
25
    public function __construct(
26
        HttpClient $httpClient = null
27
    ) {
28
        $this->httpClient = $httpClient ?: $this->discoverHttpClient();
29
    }
30
}
31