Completed
Pull Request — master (#52)
by Rafał
04:38
created

MetadataHandler::getSubscribingMethods()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 0
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