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::serialize()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 10
ccs 0
cts 7
cp 0
rs 9.4285
cc 2
eloc 6
nc 2
nop 1
crap 6
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
}