Test Failed
Branch master (cd46ea)
by Hirofumi
02:16
created

JMSJobSerializer::deserialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
namespace Shippinno\Job\Infrastructure\Domain\Model;
4
5
use JMS\Serializer\Serializer;
6
use JMS\Serializer\SerializerBuilder;
7
use Shippinno\Job\Domain\Model\Job;
8
use Shippinno\Job\Domain\Model\JobSerializer;
9
10 View Code Duplication
class JMSJobSerializer implements JobSerializer
0 ignored issues
show
Duplication introduced by
This class 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...
11
{
12
    /**
13
     * @var Serializer
14
     */
15
    private $serializer;
16
17
    /**
18
     * @param SerializerBuilder $serializerBuilder
19
     */
20
    public function __construct(SerializerBuilder $serializerBuilder)
21
    {
22
        $this->serializer =
23
            $serializerBuilder
24
                ->addMetadataDir(
25
                    __DIR__ . '/../../Serialization/JMS/Config',
26
                    'Shippinno\\Job'
27
                )
28
                ->build();
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function serialize(Job $job): string
35
    {
36
        return $this->serializer->serialize($job, 'json');
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function deserialize(string $data, string $class): Job
43
    {
44
        return $this->serializer->deserialize($data, $class, 'json');
45
    }
46
}
47