Completed
Push — master ( 79d24d...ad8160 )
by Thomas Mauro
03:36
created

AbstractServiceBuilder::getHttpClient()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 4
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Facile\OpenIDClient\Service\Builder;
6
7
use Http\Discovery\Psr17FactoryDiscovery;
8
use Http\Discovery\Psr18ClientDiscovery;
9
use Psr\Http\Client\ClientInterface;
10
use Psr\Http\Message\RequestFactoryInterface;
11
12
abstract class AbstractServiceBuilder
13
{
14
    /** @var null|ClientInterface */
15
    private $httpClient;
16
17
    /** @var null|RequestFactoryInterface */
18
    private $requestFactory;
19
20
    public function setHttpClient(ClientInterface $httpClient): void
21
    {
22
        $this->httpClient = $httpClient;
23
    }
24
25
    public function setRequestFactory(RequestFactoryInterface $requestFactory): void
26
    {
27
        $this->requestFactory = $requestFactory;
28
    }
29
30
    protected function getHttpClient(): ClientInterface
31
    {
32
        return $this->httpClient = $this->httpClient ?? Psr18ClientDiscovery::find();
33
    }
34
35
    protected function getRequestFactory(): RequestFactoryInterface
36
    {
37
        return $this->requestFactory = $this->requestFactory ?? Psr17FactoryDiscovery::findRequestFactory();
38
    }
39
}
40