|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Class HTTPClientAbstract |
|
4
|
|
|
* |
|
5
|
|
|
* @filesource HTTPClientAbstract.php |
|
6
|
|
|
* @created 22.02.2019 |
|
7
|
|
|
* @package chillerlan\HTTP\Psr18 |
|
8
|
|
|
* @author smiley <[email protected]> |
|
9
|
|
|
* @copyright 2019 smiley |
|
10
|
|
|
* @license MIT |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace chillerlan\HTTP\Psr18; |
|
14
|
|
|
|
|
15
|
|
|
use chillerlan\HTTP\HTTPOptions; |
|
16
|
|
|
use chillerlan\HTTP\Psr17\{ResponseFactory}; |
|
17
|
|
|
use chillerlan\Settings\SettingsContainerInterface; |
|
18
|
|
|
use Fig\Http\Message\RequestMethodInterface; |
|
19
|
|
|
use Psr\Http\Client\ClientInterface; |
|
20
|
|
|
use Psr\Http\Message\ResponseFactoryInterface; |
|
21
|
|
|
use Psr\Log\{LoggerAwareInterface, LoggerAwareTrait, LoggerInterface, NullLogger}; |
|
22
|
|
|
|
|
23
|
|
|
abstract class HTTPClientAbstract implements ClientInterface, LoggerAwareInterface, RequestMethodInterface{ |
|
24
|
|
|
use LoggerAwareTrait; |
|
25
|
|
|
|
|
26
|
|
|
/** @var \chillerlan\Settings\SettingsContainerInterface|\chillerlan\HTTP\HTTPOptions */ |
|
27
|
|
|
protected SettingsContainerInterface $options; |
|
28
|
|
|
|
|
29
|
|
|
protected ResponseFactoryInterface $responseFactory; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* HTTPClientAbstract constructor. |
|
33
|
|
|
*/ |
|
34
|
|
|
public function __construct( |
|
35
|
|
|
SettingsContainerInterface $options = null, |
|
36
|
|
|
ResponseFactoryInterface $responseFactory = null, |
|
37
|
|
|
LoggerInterface $logger = null |
|
38
|
|
|
){ |
|
39
|
|
|
$this->options = $options ?? new HTTPOptions; |
|
40
|
|
|
$this->responseFactory = $responseFactory ?? new ResponseFactory; |
|
41
|
|
|
$this->logger = $logger ?? new NullLogger; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
} |
|
45
|
|
|
|