|
7 | 7 | * @license MIT |
8 | 8 | */ |
9 | 9 |
|
10 | | -use chillerlan\HTTP\{CurlClient, HTTPClientAbstract, HTTPResponseInterface}; |
| 10 | +use chillerlan\HTTP\CurlClient; |
11 | 11 | use chillerlan\Logger\{Log, LogOptionsTrait, Output\ConsoleLog}; |
12 | 12 | use chillerlan\OAuth\{OAuthOptions, Storage\SessionStorage}; |
13 | | -use chillerlan\Traits\{DotEnv, ImmutableSettingsInterface}; |
| 13 | +use chillerlan\DotEnv\DotEnv; |
14 | 14 |
|
15 | 15 | ini_set('date.timezone', 'Europe/Amsterdam'); |
16 | 16 |
|
|
32 | 32 |
|
33 | 33 | // log |
34 | 34 | 'minLogLevel' => 'debug', |
35 | | - |
36 | | - // test http client |
37 | | - 'sleep' => 0.25, |
38 | 35 | ]; |
39 | 36 |
|
40 | | -/** @var \chillerlan\Traits\ImmutableSettingsInterface $options */ |
| 37 | +/** @var \chillerlan\Settings\SettingsContainerInterface $options */ |
41 | 38 | $options = new class($options_arr) extends OAuthOptions{ |
42 | 39 | use LogOptionsTrait; |
43 | 40 |
|
44 | 41 | protected $sleep; |
45 | 42 | }; |
46 | 43 |
|
47 | 44 | $logger = new Log; |
48 | | -$logger->addInstance(new ConsoleLog($options), 'console'); |
| 45 | +$logger->addInstance(new ConsoleLog, 'console'); |
49 | 46 |
|
50 | 47 | /** @var \chillerlan\HTTP\HTTPClientInterface $http */ |
51 | | -$http = new class($options) extends HTTPClientAbstract{ |
52 | | - |
53 | | - protected $client; |
54 | | - |
55 | | - public function __construct(ImmutableSettingsInterface $options){ |
56 | | - parent::__construct($options); |
57 | | - $this->client = new CurlClient($this->options); |
58 | | - } |
59 | | - |
60 | | - protected function getResponse():HTTPResponseInterface{ |
61 | | - |
62 | | - $this->logger->debug('$args', [ |
63 | | - '$url' => $this->requestURL, |
64 | | - '$params' => $this->requestParams, |
65 | | - '$method' => $this->requestMethod, |
66 | | - '$body' => $this->requestBody, |
67 | | - '$headers' => $this->requestHeaders, |
68 | | - ]); |
69 | | - |
70 | | - $response = $this->client->request($this->requestURL, $this->requestParams, $this->requestMethod, $this->requestBody, $this->requestHeaders); |
71 | | - |
72 | | - $this->logger->debug($response->body, (array)$response->headers); |
73 | | - |
74 | | - usleep($this->options->sleep * 1000000); |
75 | | - |
76 | | - return $response; |
77 | | - } |
78 | | - |
79 | | -}; |
80 | | - |
81 | | -#$http->setLogger($logger); |
| 48 | +$http = new CurlClient($options); |
82 | 49 |
|
83 | 50 | /** @var \chillerlan\OAuth\Storage\OAuthStorageInterface $storage */ |
84 | | -$storage = new SessionStorage($options); |
| 51 | +$storage = new SessionStorage; |
85 | 52 | #$storage->setLogger($logger); |
0 commit comments