Passed
Push — main ( 5b8cd4...64b6a7 )
by smiley
01:44
created

HTTPClientAbstract::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
nc 1
nop 3
dl 0
loc 9
rs 10
c 3
b 0
f 0
1
<?php
2
/**
3
 * Class HTTPClientAbstract
4
 *
5
 * @created      22.02.2019
6
 * @author       smiley <[email protected]>
7
 * @copyright    2019 smiley
8
 * @license      MIT
9
 */
10
11
namespace chillerlan\HTTP\Psr18;
12
13
use chillerlan\HTTP\HTTPOptions;
14
use chillerlan\HTTP\Psr17\{ResponseFactory};
15
use chillerlan\Settings\SettingsContainerInterface;
16
use Fig\Http\Message\RequestMethodInterface;
17
use Psr\Http\Client\ClientInterface;
18
use Psr\Http\Message\ResponseFactoryInterface;
19
use Psr\Log\{LoggerAwareInterface, LoggerAwareTrait, LoggerInterface, NullLogger};
20
21
abstract class HTTPClientAbstract implements ClientInterface, LoggerAwareInterface, RequestMethodInterface{
22
	use LoggerAwareTrait;
23
24
	/** @var \chillerlan\Settings\SettingsContainerInterface|\chillerlan\HTTP\HTTPOptions */
25
	protected SettingsContainerInterface $options;
26
27
	protected ResponseFactoryInterface $responseFactory;
28
29
	/**
30
	 * HTTPClientAbstract constructor.
31
	 */
32
	public function __construct(
33
		SettingsContainerInterface $options = null,
34
		ResponseFactoryInterface $responseFactory = null,
35
		LoggerInterface $logger = null
36
	){
37
		$this->options = $options ?? new HTTPOptions;
38
39
		$this->setResponseFactory($responseFactory ?? new ResponseFactory);
40
		$this->setLogger($logger ?? new NullLogger);
41
	}
42
43
	/**
44
	 * @codeCoverageIgnore
45
	 */
46
	public function setResponseFactory(ResponseFactory $responseFactory):self{
47
		$this->responseFactory = $responseFactory;
48
49
		return $this;
50
	}
51
52
}
53