Skip to content

Commit 904f7b8

Browse files
committed
:octocat:
1 parent a916f40 commit 904f7b8

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

src/CurlClient.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@ class CurlClient extends HTTPClientAbstract{
2424
*/
2525
protected $responseHeaders;
2626

27-
/** @inheritdoc */
27+
/**
28+
* CurlClient constructor.
29+
*
30+
* @param \chillerlan\Traits\ContainerInterface $options
31+
*
32+
* @throws \chillerlan\HTTP\HTTPClientException
33+
*/
2834
public function __construct(ContainerInterface $options){
2935
parent::__construct($options);
3036

@@ -34,8 +40,6 @@ public function __construct(ContainerInterface $options){
3440

3541
$this->http = curl_init();
3642

37-
curl_setopt_array($this->http, $this->options->curl_options);
38-
3943
curl_setopt_array($this->http, [
4044
CURLOPT_HEADER => false,
4145
CURLOPT_RETURNTRANSFER => true,
@@ -47,6 +51,7 @@ public function __construct(ContainerInterface $options){
4751
CURLOPT_USERAGENT => $this->options->user_agent,
4852
]);
4953

54+
curl_setopt_array($this->http, $this->options->curl_options);
5055
}
5156

5257
/** @inheritdoc */

src/HTTPClientAbstract.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@
1313
namespace chillerlan\HTTP;
1414

1515
use chillerlan\Traits\ContainerInterface;
16+
use Psr\Log\{
17+
LoggerAwareInterface, LoggerAwareTrait, LoggerInterface, NullLogger
18+
};
1619

17-
abstract class HTTPClientAbstract implements HTTPClientInterface{
20+
abstract class HTTPClientAbstract implements HTTPClientInterface, LoggerAwareInterface{
21+
use LoggerAwareTrait;
1822

1923
/**
2024
* @var mixed
@@ -27,8 +31,9 @@ abstract class HTTPClientAbstract implements HTTPClientInterface{
2731
protected $options;
2832

2933
/** @inheritdoc */
30-
public function __construct(ContainerInterface $options){
34+
public function __construct(ContainerInterface $options, LoggerInterface $logger = null){
3135
$this->options = $options;
36+
$this->logger = $logger ?? new NullLogger;
3237
}
3338

3439
/** @inheritdoc */
@@ -66,7 +71,7 @@ public function rawurlencode($data){
6671
return rawurlencode($data);
6772
}
6873

69-
return $data;
74+
return $data; // @codeCoverageIgnore
7075
}
7176

7277
/**

src/HTTPClientInterface.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,8 @@
1212

1313
namespace chillerlan\HTTP;
1414

15-
use chillerlan\Traits\ContainerInterface;
16-
1715
interface HTTPClientInterface{
1816

19-
/**
20-
* HTTPClientInterface constructor.
21-
*
22-
* @param \chillerlan\Traits\ContainerInterface $options
23-
*/
24-
public function __construct(ContainerInterface $options);
25-
2617
/**
2718
* @param string $url
2819
* @param array|null $params

0 commit comments

Comments
 (0)