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.

Serializer   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 56.25%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
c 1
b 0
f 1
lcom 0
cbo 4
dl 0
loc 36
ccs 9
cts 16
cp 0.5625
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A deserialize() 0 13 2
A serialize() 0 10 2
1
<?php
2
/**
3
 * Copyright (c) 2016, HelloFresh GmbH.
4
 * All rights reserved.
5
 *
6
 * This source code is licensed under the MIT license found in the
7
 * LICENSE file in the root directory of this source tree.
8
 */
9
10
namespace HelloFresh\FeatureToggle\Serializer;
11
12
use Collections\Dictionary;
13
use Collections\MapInterface;
14
15
class Serializer
16
{
17
    /**
18
     * @param array $data
19
     * @return MapInterface
20
     */
21 1
    public function deserialize(array $data)
22
    {
23 1
        $data = new Dictionary($data);
24
25 1
        $collection = new Dictionary();
26 1
        $serializer = new ToggleSerializer(new OperatorConditionSerializer(new OperatorSerializer()));
27 1
        foreach ($data as $name => $serializedToggle) {
28 1
            $toggle = $serializer->deserialize($serializedToggle);
29 1
            $collection->set($serializedToggle->get('name'), $toggle);
30 1
        }
31
32 1
        return $collection;
33
    }
34
35
36
    /**
37
     * @param MapInterface $features
38
     * @return array
39
     */
40
    public function serialize(MapInterface $features)
41
    {
42
        $serializer = new ToggleSerializer(new OperatorConditionSerializer(new OperatorSerializer()));
43
        $ret = [];
44
        foreach ($features as $key => $toggle) {
45
            $ret[$key] = $serializer->serialize($toggle);
46
        }
47
48
        return $ret;
49
    }
50
}