Completed
Push — master ( d8a1ad...d0379b )
by Dominik
02:06
created

Deserializer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 39
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A deserialize() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chubbyphp\Deserialization;
6
7
use Chubbyphp\Deserialization\Decoder\DecoderInterface;
8
use Chubbyphp\Deserialization\Denormalizer\DenormalizerContextInterface;
9
use Chubbyphp\Deserialization\Denormalizer\DenormalizerInterface;
10
11
final class Deserializer implements DeserializerInterface
12
{
13
    /**
14
     * @var DecoderInterface
15
     */
16
    private $decoder;
17
18
    /**
19
     * @var DenormalizerInterface
20
     */
21
    private $denormalizer;
22
23
    /**
24
     * @param DecoderInterface      $decoder
25
     * @param DenormalizerInterface $denormalizer
26
     */
27 4
    public function __construct(DecoderInterface $decoder, DenormalizerInterface $denormalizer)
28
    {
29 4
        $this->decoder = $decoder;
30 4
        $this->denormalizer = $denormalizer;
31 4
    }
32
33
    /**
34
     * @param object|string                $object
35
     * @param string                       $data
36
     * @param string                       $contentType
37
     * @param DenormalizerContextInterface $context
38
     *
39
     * @return object
40
     */
41 4
    public function deserialize(
42
        $object,
43
        string $data,
44
        string $contentType,
45
        DenormalizerContextInterface $context = null
46
    ) {
47 4
        return $this->denormalizer->denormalize($object, $this->decoder->decode($data, $contentType), $context);
48
    }
49
}
50