Completed
Push — master ( a15a3c...decc90 )
by
unknown
04:44
created

JMSSerializer::getDefaultFormat()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace MediaMonks\RestApiBundle\Serializer;
4
5
use JMS\Serializer\Serializer;
6
use JMS\Serializer\SerializationContext;
7
use MediaMonks\RestApiBundle\Request\Format;
8
9
class JMSSerializer extends AbstractSerializer implements SerializerInterface
10
{
11
    /**
12
     * @var Serializer
13
     */
14
    private $serializer;
15
16
    /**
17
     * @var SerializationContext
18
     */
19
    private $context;
20
21
    /**
22
     * @param Serializer $serializer
23
     * @param SerializationContext|null $context
24
     */
25 4
    public function __construct(Serializer $serializer, SerializationContext $context = null)
26
    {
27 4
        $this->serializer = $serializer;
28 4
        $this->context = $context;
29 4
    }
30
31
    /**
32
     * @param $data
33
     * @param $format
34
     * @return mixed|string
35
     */
36 2
    public function serialize($data, $format)
37
    {
38 2
        return $this->serializer->serialize($data, $format, $this->context);
39
    }
40
41
    /**
42
     * @return array
43
     */
44 2
    public function getSupportedFormats()
45
    {
46 2
        return [Format::FORMAT_JSON, Format::FORMAT_XML];
47
    }
48
49
    /**
50
     * @return string
51
     */
52 1
    public function getDefaultFormat()
53
    {
54 1
        return Format::FORMAT_JSON;
55
    }
56
}
57