Completed
Pull Request — master (#9)
by Hugo
01:42
created

AbstractClient::getHttpClient()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
1
<?php
2
3
namespace Yproximite\Api\Client;
4
5
use Http\Client\HttpClient;
6
use Http\Discovery\MessageFactoryDiscovery;
7
use Http\Message\MessageFactory;
8
9
abstract class AbstractClient
10
{
11
    private $httpClient;
12
    private $messageFactory;
13
14
    public function __construct(HttpClient $httpClient = null, MessageFactory $messageFactory = null)
15
    {
16
        $this->httpClient     = $httpClient;
17
        $this->messageFactory = $messageFactory;
18
    }
19
20
    protected function getHttpClient(): HttpClient
21
    {
22
        if ($this->httpClient === null) {
23
            $this->httpClient = MessageFactoryDiscovery::find();
24
        }
25
26
        return $this->httpClient;
27
    }
28
29
    protected function getMessageFactory(): MessageFactory
30
    {
31
        if ($this->messageFactory === null) {
32
            $this->messageFactory = MessageFactoryDiscovery::find();
33
        }
34
35
        return $this->messageFactory;
36
    }
37
}
38