AbstractServiceBuilder   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 30
ccs 0
cts 10
cp 0
rs 10
c 2
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setRequestFactory() 0 5 1
A getHttpClient() 0 3 1
A getRequestFactory() 0 3 1
A setHttpClient() 0 5 1
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