Test Failed
Push — master ( 25b8d1...f70cb8 )
by Pavel
03:49
created

JmsSerializerAdapter::deserialize()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 9
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 9
loc 9
rs 9.6666
cc 2
eloc 5
nc 2
nop 4
1
<?php
2
3
namespace ScayTrase\Api\Cruds\Adaptors\Jms;
4
5
use JMS\Serializer\DeserializationContext;
6
use JMS\Serializer\SerializationContext;
7
use JMS\Serializer\SerializerInterface as JmsSerializer;
8
use Symfony\Component\Serializer\SerializerInterface;
9
10
final class JmsSerializerAdapter implements SerializerInterface
11
{
12
    /** @var  JmsSerializer */
13
    private $serializer;
14
15
    /**
16
     * JmsSerializerAdapter constructor.
17
     *
18
     * @param JmsSerializer $serializer
19
     */
20
    public function __construct(JmsSerializer $serializer)
21
    {
22
        $this->serializer = $serializer;
23
    }
24
25
    /** {@inheritdoc} */
26 View Code Duplication
    public function serialize($data, $format, array $context = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
27
    {
28
        $jmsContext = SerializationContext::create();
29
        if (array_key_exists('groups', $context)) {
30
            $jmsContext->setGroups($context['groups']);
31
        }
32
33
        return $this->serializer->serialize($data, $format, $jmsContext);
34
    }
35
36
    /** {@inheritdoc} */
37 View Code Duplication
    public function deserialize($data, $type, $format, array $context = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
38
    {
39
        $jmsContext = DeserializationContext::create();
40
        if (array_key_exists('groups', $context)) {
41
            $jmsContext->setGroups($context['groups']);
42
        }
43
44
        $this->serializer->deserialize($data, $type, $format, $jmsContext);
45
    }
46
}
47