Total Complexity | 3 |
Total Lines | 35 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
15 | class Client implements HttpClientInterface |
||
16 | { |
||
17 | /** |
||
18 | * The HTTP client. |
||
19 | * |
||
20 | * @var \Symfony\Contracts\HttpClient\HttpClientInterface |
||
21 | */ |
||
22 | private $httpClient; |
||
23 | |||
24 | /** |
||
25 | * Client constructor. |
||
26 | * |
||
27 | * @param null|\Symfony\Contracts\HttpClient\HttpClientInterface $httpClient |
||
28 | */ |
||
29 | public function __construct(HttpClientInterface $httpClient = null) |
||
30 | { |
||
31 | $this->httpClient = $httpClient ?? new NativeHttpClient(); |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * {@inheritdoc} |
||
36 | */ |
||
37 | public function request(string $method, string $url, array $options = []): ResponseInterface |
||
38 | { |
||
39 | $options['headers']['User-Agent'] = 'YAROC (http://github.com/drupol/yaroc)'; |
||
40 | |||
41 | return $this->httpClient->request($method, $url, $options); |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * {@inheritdoc} |
||
46 | */ |
||
47 | public function stream($responses, float $timeout = null): ResponseStreamInterface |
||
50 | } |
||
51 | } |
||
52 |