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

Serializer::serializeFields()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 20
Code Lines 15

Duplication

Lines 20
Ratio 100 %

Code Coverage

Tests 10
CRAP Score 3

Importance

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