Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
18 / 18
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
Psr7ServiceProvider
100.00% covered (success)
100.00%
18 / 18
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
1 / 1
 register
100.00% covered (success)
100.00%
18 / 18
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3declare(strict_types=1);
4
5namespace Engelsystem\Http;
6
7use Engelsystem\Container\ServiceProvider;
8use Nyholm\Psr7\Factory\Psr17Factory;
9use Psr\Http\Message\ResponseFactoryInterface;
10use Psr\Http\Message\ResponseInterface;
11use Psr\Http\Message\ServerRequestFactoryInterface;
12use Psr\Http\Message\ServerRequestInterface;
13use Psr\Http\Message\StreamFactoryInterface;
14use Psr\Http\Message\UploadedFileFactoryInterface;
15use Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory;
16use Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface;
17
18class 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}