Passed
Branch master (a7861d)
by Dominik
03:10
created

ApiHttpProvider   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

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

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
use Pimple\ServiceProviderInterface;
12
13
final class ApiHttpProvider implements ServiceProviderInterface
14
{
15
    /**
16
     * @param Container $container
17
     */
18
    public function register(Container $container)
19
    {
20 1
        $container['api-http.request.manager'] = function () use ($container) {
21 1
            return new RequestManager(
22 1
                $container['api-http.request.contentNegotiator'],
23 1
                $container['deserializer'],
24 1
                $container['deserializer.transformer']
25
            );
26
        };
27
28 1
        $container['api-http.request.contentNegotiator'] = function () {
29 1
            return new ContentNegotiator();
30
        };
31
32 1
        $container['api-http.response.manager'] = function () use ($container) {
33 1
            return new ResponseManager(
34 1
                $container['api-http.request.manager'],
35 1
                $container['api-http.response.factory'],
36 1
                $container['serializer'],
37 1
                $container['serializer.transformer']
38
            );
39
        };
40
41 1
        $container['api-http.response.factory'] = function () {
42 1
            throw new \RuntimeException('Missing response factory, define service "api-http.response.factory"');
43
        };
44
    }
45
}
46