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

JMSStoredJobSerializer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 37
loc 37
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 10 10 1
A serialize() 4 4 1
A deserialize() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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\StoredJob;
8
use Shippinno\Job\Domain\Model\StoredJobSerializer;
9
10 View Code Duplication
class JMSStoredJobSerializer implements StoredJobSerializer
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(StoredJob $storedJob): string
35
    {
36
        return $this->serializer->serialize($storedJob, 'json');
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function deserialize(string $data): StoredJob
43
    {
44
        return $this->serializer->deserialize($data, StoredJob::class, 'json');
45
    }
46
}
47