Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| HttpClientServiceProvider | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| register | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Engelsystem\Http; |
| 6 | |
| 7 | use Engelsystem\Application; |
| 8 | use Engelsystem\Container\ServiceProvider; |
| 9 | use GuzzleHttp\Client as GuzzleClient; |
| 10 | |
| 11 | class HttpClientServiceProvider extends ServiceProvider |
| 12 | { |
| 13 | public function register(): void |
| 14 | { |
| 15 | $this->app->when(GuzzleClient::class) |
| 16 | ->needs('$config') |
| 17 | ->give( |
| 18 | function (Application $app) { |
| 19 | return [ |
| 20 | // No exception on >= 400 responses |
| 21 | 'http_errors' => false, |
| 22 | // Wait max n seconds for a response |
| 23 | 'timeout' => $app->get('config')->get('guzzle_timeout'), |
| 24 | ]; |
| 25 | } |
| 26 | ); |
| 27 | } |
| 28 | } |