Completed
Push — master ( 5b43bc...296862 )
by Dominik
01:42
created

ApiHttpProvider   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 33
c 1
b 0
f 1
wmc 1
lcom 0
cbo 3
ccs 0
cts 23
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B register() 0 27 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chubbyphp\ApiHttp\Provider;
6
7
use Chubbyphp\ApiHttp\Manager\RequestManager;
8
use Chubbyphp\ApiHttp\Manager\ResponseManager;
9
use Negotiation\Negotiator as ContentNegotiator;
10
use Pimple\Container;
11
12
final class ApiHttpProvider
13
{
14
    /**
15
     * @param Container $container
16
     */
17
    public function register(Container $container)
18
    {
19
        $container['api-http.request.manager'] = function () use ($container) {
20
            return new RequestManager(
21
                $container['api-http.request.contentNegotiator'],
22
                $container['deserializer'],
23
                $container['deserializer.transformer']
24
            );
25
        };
26
27
        $container['api-http.request.contentNegotiator'] = function () {
28
            return new ContentNegotiator();
29
        };
30
31
        $container['api-http.request.manager'] = function () use ($container) {
32
            return new ResponseManager(
33
                $container['api-http.request.manager'],
34
                $container['api-http.response.factory'],
35
                $container['serializer'],
36
                $container['serializer.transformer']
37
            );
38
        };
39
40
        $container['api-http.response.factory'] = function () {
41
            throw new \RuntimeException('Missing response factory, define service "api-http.response.factory"');
42
        };
43
    }
44
}
45