IdSubscribingHandler   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 16.66%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubscribingMethods() 0 16 2
A serializeId() 0 4 1
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
class IdSubscribingHandler implements SubscribingHandlerInterface
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