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

ApiHttpProvider::register()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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