Completed
Pull Request — master (#52)
by Rafał
14:29
created

MetadataHandler   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 25
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubscribingMethods() 0 11 1
A serializeToJson() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PH\Bundle\SubscriptionBundle\Serializer;
6
7
use Doctrine\Common\Collections\Collection;
8
use JMS\Serializer\GraphNavigator;
9
use JMS\Serializer\Handler\SubscribingHandlerInterface;
10
use JMS\Serializer\JsonSerializationVisitor;
11
use PH\Component\Subscription\Model\MetadataInterface;
12
13
final class MetadataHandler implements SubscribingHandlerInterface
14
{
15
    public static function getSubscribingMethods()
16
    {
17
        return [
18
            [
19
                'direction' => GraphNavigator::DIRECTION_SERIALIZATION,
20
                'format' => 'json',
21
                'type' => MetadataInterface::class,
22
                'method' => 'serializeToJson',
23
            ],
24
        ];
25
    }
26
27
    public function serializeToJson(JsonSerializationVisitor $visitor, Collection $metadata)
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...
28
    {
29
        $result = [];
30
31
        foreach ((array) $metadata->toArray() as $item) {
32
            $result[$item->getKey()] = $item->getValue();
33
        }
34
35
        return $result;
36
    }
37
}
38