AbstractServiceBuilder::setRequestFactory()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
ccs 0
cts 3
cp 0
crap 2
rs 10
c 1
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): self
21
    {
22
        $this->httpClient = $httpClient;
23
24
        return $this;
25
    }
26
27
    public function setRequestFactory(RequestFactoryInterface $requestFactory): self
28
    {
29
        $this->requestFactory = $requestFactory;
30
31
        return $this;
32
    }
33
34
    protected function getHttpClient(): ClientInterface
35
    {
36
        return $this->httpClient = $this->httpClient ?? Psr18ClientDiscovery::find();
37
    }
38
39
    protected function getRequestFactory(): RequestFactoryInterface
40
    {
41
        return $this->requestFactory = $this->requestFactory ?? Psr17FactoryDiscovery::findRequestFactory();
42
    }
43
}
44