Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
18 / 18 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
Psr7ServiceProvider | |
100.00% |
18 / 18 |
|
100.00% |
1 / 1 |
2 | |
100.00% |
1 / 1 |
register | |
100.00% |
18 / 18 |
|
100.00% |
1 / 1 |
2 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace Engelsystem\Http; |
6 | |
7 | use Engelsystem\Container\ServiceProvider; |
8 | use Nyholm\Psr7\Factory\Psr17Factory; |
9 | use Psr\Http\Message\ResponseFactoryInterface; |
10 | use Psr\Http\Message\ResponseInterface; |
11 | use Psr\Http\Message\ServerRequestFactoryInterface; |
12 | use Psr\Http\Message\ServerRequestInterface; |
13 | use Psr\Http\Message\StreamFactoryInterface; |
14 | use Psr\Http\Message\UploadedFileFactoryInterface; |
15 | use Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory; |
16 | use Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface; |
17 | |
18 | class Psr7ServiceProvider extends ServiceProvider |
19 | { |
20 | public function register(): void |
21 | { |
22 | $psr17Factory = Psr17Factory::class; |
23 | |
24 | foreach ( |
25 | [ |
26 | 'psr7.factory.request', |
27 | ServerRequestFactoryInterface::class, |
28 | 'psr7.factory.response', |
29 | ResponseFactoryInterface::class, |
30 | 'psr7.factory.upload', |
31 | UploadedFileFactoryInterface::class, |
32 | 'psr7.factory.stream', |
33 | StreamFactoryInterface::class, |
34 | ] as $alias |
35 | ) { |
36 | $this->app->bind($alias, $psr17Factory); |
37 | } |
38 | |
39 | $this->app->bind('psr7.factory', PsrHttpFactory::class); |
40 | $this->app->bind(HttpMessageFactoryInterface::class, PsrHttpFactory::class); |
41 | |
42 | $this->app->bind('psr7.request', 'request'); |
43 | $this->app->bind(ServerRequestInterface::class, 'psr7.request'); |
44 | |
45 | $this->app->bind('psr7.response', 'response'); |
46 | $this->app->bind(ResponseInterface::class, 'psr7.response'); |
47 | } |
48 | } |