ApiHttpProvider::register()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 3
Bugs 1 Features 1
Metric Value
cc 1
eloc 9
nc 1
nop 1
dl 0
loc 16
ccs 6
cts 6
cp 1
crap 1
rs 9.9666
c 3
b 1
f 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 Pimple\Container;
10
use Pimple\ServiceProviderInterface;
11
12
final class ApiHttpProvider implements ServiceProviderInterface
13
{
14
    public function register(Container $container): void
15
    {
16
        $container['api-http.request.manager'] = static function () use ($container) {
17 2
            return new RequestManager($container['deserializer']);
18
        };
19
20 1
        $container['api-http.response.manager'] = static function () use ($container) {
21
            return new ResponseManager(
22
                $container['deserializer'],
23
                $container['api-http.response.factory'],
24 1
                $container['serializer']
25 1
            );
26 1
        };
27 1
28
        $container['api-http.response.factory'] = static function (): void {
29
            throw new \RuntimeException('Missing response factory, define service "api-http.response.factory"');
30
        };
31
    }
32
}
33