Test Failed
Push — master ( 8a2b60...8e4848 )
by Dominik
03:00
created

Serializer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A serialize() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chubbyphp\Serialization;
6
7
use Chubbyphp\Serialization\Encoder\EncoderInterface;
8
use Chubbyphp\Serialization\Normalizer\NormalizerContextInterface;
9
use Chubbyphp\Serialization\Normalizer\NormalizerInterface;
10
11
final class Serializer implements SerializerInterface
12
{
13
    /**
14
     * @var NormalizerInterface
15
     */
16
    private $normalizer;
17
18
    /**
19
     * @var EncoderInterface
20
     */
21
    private $encoder;
22
23
    /**
24
     * @param NormalizerInterface $normalizer
25
     * @param EncoderInterface    $encoder
26
     */
27
    public function __construct(NormalizerInterface $normalizer, EncoderInterface $encoder)
28
    {
29 2
        $this->normalizer = $normalizer;
30
        $this->encoder = $encoder;
31 2
    }
32 2
33 2
    /**
34
     * @param object                     $object
35
     * @param string                     $contentType
36
     * @param NormalizerContextInterface $context
37
     *
38
     * @return string
39
     */
40
    public function serialize($object, string $contentType, NormalizerContextInterface $context = null): string
41
    {
42
        return $this->encoder->encode($this->normalizer->normalize($object, $context));
0 ignored issues
show
Bug introduced by
The call to encode() misses a required argument $contentType.

This check looks for function calls that miss required arguments.

Loading history...
43
    }
44
}
45