Passed
Push — master ( f38e20...a7861d )
by Dominik
01:49
created

ApiHttpProvider::register()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 15
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 27
ccs 15
cts 15
cp 1
rs 8.8571
c 1
b 0
f 1
cc 1
eloc 16
nc 1
nop 1
crap 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