GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

JsonHalSerializer   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 9
c 0
b 0
f 0
lcom 0
cbo 2
dl 0
loc 57
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B serializeLinks() 0 22 5
B serializeEmbeddeds() 0 25 4
1
<?php
2
3
namespace Hateoas\Serializer;
4
5
use JMS\Serializer\JsonSerializationVisitor;
6
use JMS\Serializer\SerializationContext;
7
8
/**
9
 * @author Adrien Brault <[email protected]>
10
 */
11
class JsonHalSerializer implements JsonSerializerInterface
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16
    public function serializeLinks(array $links, JsonSerializationVisitor $visitor, SerializationContext $context)
17
    {
18
        $serializedLinks = array();
19
        foreach ($links as $link) {
20
            $serializedLink = array_merge(array(
21
                'href' => $link->getHref(),
22
            ), $link->getAttributes());
23
24
            if (!isset($serializedLinks[$link->getRel()]) && 'curies' !== $link->getRel()) {
25
                $serializedLinks[$link->getRel()] = $serializedLink;
26
            } elseif (isset($serializedLinks[$link->getRel()]['href'])) {
27
                $serializedLinks[$link->getRel()] = array(
28
                    $serializedLinks[$link->getRel()],
29
                    $serializedLink
30
                );
31
            } else {
32
                $serializedLinks[$link->getRel()][] = $serializedLink;
33
            }
34
        }
35
36
        $visitor->addData('_links', $serializedLinks);
0 ignored issues
show
Deprecated Code introduced by Adrien Brault
The method JMS\Serializer\JsonSerializationVisitor::addData() has been deprecated with message: use setData instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function serializeEmbeddeds(array $embeddeds, JsonSerializationVisitor $visitor, SerializationContext $context)
43
    {
44
        $serializedEmbeddeds = array();
45
        $multiple = array();
46
        foreach ($embeddeds as $embedded) {
47
            $context->pushPropertyMetadata($embedded->getMetadata());
48
49
            if (!isset($serializedEmbeddeds[$embedded->getRel()])) {
50
                $serializedEmbeddeds[$embedded->getRel()] = $context->accept($embedded->getData());
51
            } elseif (!isset($multiple[$embedded->getRel()])) {
52
                $multiple[$embedded->getRel()] = true;
53
54
                $serializedEmbeddeds[$embedded->getRel()] = array(
55
                    $serializedEmbeddeds[$embedded->getRel()],
56
                    $context->accept($embedded->getData()),
57
                );
58
            } else {
59
                $serializedEmbeddeds[$embedded->getRel()][] = $context->accept($embedded->getData());
60
            }
61
62
            $context->popPropertyMetadata();
63
        }
64
65
        $visitor->addData('_embedded', $serializedEmbeddeds);
0 ignored issues
show
Deprecated Code introduced by William DURAND
The method JMS\Serializer\JsonSerializationVisitor::addData() has been deprecated with message: use setData instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
66
    }
67
}
68