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

Serializer::serialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 0
cts 0
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 3
crap 2
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