RamseyUuidHandler   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 80%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 40
ccs 16
cts 20
cp 0.8
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubscribingMethods() 0 23 2
A serializeUuid() 0 5 1
A deserializeUuid() 0 5 1
1
<?php
2
3
namespace Governor\Framework\Serializer\Handlers;
4
5
use JMS\Serializer\Context;
6
use JMS\Serializer\GraphNavigator;
7
use JMS\Serializer\VisitorInterface;
8
use JMS\Serializer\Handler\SubscribingHandlerInterface;
9
use Ramsey\Uuid\Uuid;
10
11
class RamseyUuidHandler implements SubscribingHandlerInterface
12
{
13
14 63
    public static function getSubscribingMethods()
15
    {
16 63
        $methods = array();
17 63
        $formats = array('json', 'xml', 'yml');
18
19 63
        foreach ($formats as $format) {
20 63
            $methods[] = array(
21 63
                'type' => 'Ramsey\Uuid\Uuid',
22 63
                'direction' => GraphNavigator::DIRECTION_SERIALIZATION,
23 63
                'format' => $format,
24
                'method' => 'serializeUuid'
25 63
            );
26
27 63
            $methods[] = array(
28 63
                'type' => 'Ramsey\Uuid\Uuid',
29 63
                'direction' => GraphNavigator::DIRECTION_DESERIALIZATION,
30 63
                'format' => $format,
31
                'method' => 'deserializeUuid'
32 63
            );
33 63
        }
34
35 63
        return $methods;
36
    }
37
38
    public function serializeUuid(VisitorInterface $visitor, Uuid $uuid,
39
            array $type, Context $context)
40
    {
41
        return $visitor->visitString($uuid->toString(), $type, $context);
42
    }
43
44
    public function deserializeUuid(VisitorInterface $visitor, $data,
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...
45
            array $type, Context $context)
0 ignored issues
show
Unused Code introduced by
The parameter $type 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...
Unused Code introduced by
The parameter $context 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...
46
    {
47
        return Uuid::fromString($data);
48
    }
49
50
}
51