XmlConverter::convert()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
3
namespace Saxulum\RestCrud\Request\Converter;
4
5
use JMS\Serializer\SerializerInterface;
6
7
class XmlConverter implements ConverterInterface
8
{
9
    /**
10
     * @var SerializerInterface
11
     */
12
    protected $serializer;
13
14
    /**
15
     * @param SerializerInterface $serializer
16
     */
17
    public function __construct(SerializerInterface $serializer)
18
    {
19
        $this->serializer = $serializer;
20
    }
21
22
    /**
23
     * @param string $content
24
     *
25
     * @return array
26
     */
27
    public function convert($content)
28
    {
29
        return  $this
30
            ->serializer
31
            ->deserialize($content, 'Saxulum\RestCrud\Request\Converter\XmlForm', 'xml')
32
            ->toArray()
33
        ;
34
    }
35
36
    /**
37
     * @return string
38
     */
39
    public function contentType()
40
    {
41
        return 'application/xml';
42
    }
43
}
44