Completed
Push — master ( 73e738...505de7 )
by Dominik
03:05
created

DeserializationProvider   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 1
c 1
b 1
f 0
lcom 0
cbo 7
dl 0
loc 48
ccs 22
cts 22
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B register() 0 42 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chubbyphp\Deserialization\Provider;
6
7
use Chubbyphp\Deserialization\Decoder\Decoder;
8
use Chubbyphp\Deserialization\Decoder\JsonDecoderType;
9
use Chubbyphp\Deserialization\Decoder\UrlEncodedDecoderType;
10
use Chubbyphp\Deserialization\Decoder\XmlDecoderType;
11
use Chubbyphp\Deserialization\Decoder\YamlDecoderType;
12
use Chubbyphp\Deserialization\Denormalizer\Denormalizer;
13
use Chubbyphp\Deserialization\Deserializer;
14
use Pimple\Container;
15
use Pimple\ServiceProviderInterface;
16
17
final class DeserializationProvider implements ServiceProviderInterface
18
{
19
    /**
20
     * @param Container $container
21
     */
22
    public function register(Container $container)
23
    {
24 1
        $container['deserializer'] = function () use ($container) {
25 1
            return new Deserializer($container['deserializer.decoder'], $container['deserializer.denormalizer']);
26
        };
27
28 1
        $container['deserializer.decoder'] = function () use ($container) {
29 1
            return new Decoder([
30 1
                $container['deserializer.decodertype.json'],
31 1
                $container['deserializer.decodertype.urlencoded'],
32 1
                $container['deserializer.decodertype.xml'],
33 1
                $container['deserializer.decodertype.yaml'],
34
            ]);
35
        };
36
37 1
        $container['deserializer.decodertype.json'] = function () {
38 1
            return new JsonDecoderType();
39
        };
40
41 1
        $container['deserializer.decodertype.urlencoded'] = function () {
42 1
            return new UrlEncodedDecoderType();
43
        };
44
45 1
        $container['deserializer.decodertype.xml'] = function () {
46 1
            return new XmlDecoderType();
47
        };
48
49 1
        $container['deserializer.decodertype.yaml'] = function () {
50 1
            return new YamlDecoderType();
51
        };
52
53 1
        $container['deserializer.denormalizer'] = function () use ($container) {
54 1
            return new Denormalizer(
55 1
                $container['deserializer.denormalizer.objectmappings'],
56 1
                $container['logger'] ?? null
57
            );
58
        };
59
60 1
        $container['deserializer.denormalizer.objectmappings'] = function () {
61 1
            return [];
62
        };
63
    }
64
}
65