Completed
Push — master ( beeeff...e349d6 )
by Christian
07:48 queued 05:00
created

Serializer   C

Complexity

Total Complexity 1

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 19

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
lcom 0
cbo 19
dl 0
loc 35
ccs 20
cts 20
cp 1
rs 6.875
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B createSerializer() 0 27 1
1
<?php
2
3
/*
4
 * This file is part of the xAPI package.
5
 *
6
 * (c) Christian Flothmann <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Xabbuh\XApi\Serializer;
13
14
use Symfony\Component\Serializer\Encoder\JsonEncoder;
15
use Symfony\Component\Serializer\Normalizer\ArrayDenormalizer;
16
use Symfony\Component\Serializer\Normalizer\PropertyNormalizer;
17
use Symfony\Component\Serializer\SerializerInterface;
18
use Symfony\Component\Serializer\Serializer as SymfonySerializer;
19
use Xabbuh\XApi\Serializer\Normalizer\ActorNormalizer;
20
use Xabbuh\XApi\Serializer\Normalizer\ContextActivitiesNormalizer;
21
use Xabbuh\XApi\Serializer\Normalizer\ContextNormalizer;
22
use Xabbuh\XApi\Serializer\Normalizer\DefinitionNormalizer;
23
use Xabbuh\XApi\Serializer\Normalizer\DocumentDataNormalizer;
24
use Xabbuh\XApi\Serializer\Normalizer\ExtensionsNormalizer;
25
use Xabbuh\XApi\Serializer\Normalizer\FilterNullValueNormalizer;
26
use Xabbuh\XApi\Serializer\Normalizer\InteractionComponentNormalizer;
27
use Xabbuh\XApi\Serializer\Normalizer\LanguageMapNormalizer;
28
use Xabbuh\XApi\Serializer\Normalizer\ObjectNormalizer;
29
use Xabbuh\XApi\Serializer\Normalizer\ResultNormalizer;
30
use Xabbuh\XApi\Serializer\Normalizer\StatementNormalizer;
31
use Xabbuh\XApi\Serializer\Normalizer\StatementResultNormalizer;
32
use Xabbuh\XApi\Serializer\Normalizer\TimestampNormalizer;
33
use Xabbuh\XApi\Serializer\Normalizer\VerbNormalizer;
34
35
/**
36
 * Entry point to set up the {@link \Symfony\Component\Serializer\Serializer Symfony Serializer component}
37
 * for the Experience API.
38
 *
39
 * @author Christian Flothmann <[email protected]>
40
 */
41
class Serializer
42
{
43
    /**
44
     * Creates a new Serializer.
45
     *
46
     * @return SerializerInterface The Serializer
47
     */
48 350
    public static function createSerializer()
49
    {
50
        $normalizers = array(
51 350
            new ActorNormalizer(),
52 350
            new ContextNormalizer(),
53 350
            new ContextActivitiesNormalizer(),
54 350
            new DefinitionNormalizer(),
55 350
            new DocumentDataNormalizer(),
56 350
            new ExtensionsNormalizer(),
57 350
            new InteractionComponentNormalizer(),
58 350
            new LanguageMapNormalizer(),
59 350
            new ObjectNormalizer(),
60 350
            new ResultNormalizer(),
61 350
            new StatementNormalizer(),
62 350
            new StatementResultNormalizer(),
63 350
            new TimestampNormalizer(),
64 350
            new VerbNormalizer(),
65 350
            new ArrayDenormalizer(),
66 350
            new FilterNullValueNormalizer(new PropertyNormalizer()),
0 ignored issues
show
Unused Code introduced by
The call to FilterNullValueNormalizer::__construct() has too many arguments starting with new \Symfony\Component\S...er\PropertyNormalizer().

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
67 350
            new PropertyNormalizer(),
68
        );
69
        $encoders = array(
70 350
            new JsonEncoder(),
71
        );
72
73 350
        return new SymfonySerializer($normalizers, $encoders);
74
    }
75
}
76