Completed
Branch master (933e97)
by Torsten
04:46
created

IdSubscribingHandler   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 16.66%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 32
loc 32
c 1
b 0
f 0
wmc 3
lcom 0
cbo 1
ccs 2
cts 12
cp 0.1666
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubscribingMethods() 16 16 2
A serializeId() 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
declare(strict_types=1);
4
5
namespace Lej\Component\Infrastructure\Serialization;
6
7
use JMS\Serializer\GraphNavigator;
8
use JMS\Serializer\Handler\SubscribingHandlerInterface;
9
use JMS\Serializer\VisitorInterface;
10
use Lej\Component\Domain\Model\Id;
11
12 View Code Duplication
class IdSubscribingHandler implements SubscribingHandlerInterface
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...
13
{
14
    /**
15
     * {@inheritdoc}
16
     */
17
    public static function getSubscribingMethods()
18
    {
19
        $methods = [];
20
        $formats = ['json'];
21
22
        foreach ($formats as $format) {
23
            $methods[] = [
24
                'type' => 'Id',
25
                'format' => $format,
26
                'direction' => GraphNavigator::DIRECTION_SERIALIZATION,
27
                'method' => 'serializeId',
28
            ];
29
        }
30
31
        return $methods;
32
    }
33
34
    /**
35
     * @param VisitorInterface $visitor
36
     * @param Id $id
37
     * @return string
38
     */
39 1
    public function serializeId(VisitorInterface $visitor, Id $id)
0 ignored issues
show
Unused Code introduced by
The parameter $visitor is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
40
    {
41 1
        return $id->toString();
42
    }
43
}
44