Completed
Push — master ( b458df...beeeff )
by Christian
06:18 queued 04:09
created

Serializer   B

Complexity

Total Complexity 1

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 18

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
lcom 0
cbo 18
dl 0
loc 34
ccs 19
cts 19
cp 1
rs 7.3333
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B createSerializer() 0 26 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\LanguageMapNormalizer;
27
use Xabbuh\XApi\Serializer\Normalizer\ObjectNormalizer;
28
use Xabbuh\XApi\Serializer\Normalizer\ResultNormalizer;
29
use Xabbuh\XApi\Serializer\Normalizer\StatementNormalizer;
30
use Xabbuh\XApi\Serializer\Normalizer\StatementResultNormalizer;
31
use Xabbuh\XApi\Serializer\Normalizer\TimestampNormalizer;
32
use Xabbuh\XApi\Serializer\Normalizer\VerbNormalizer;
33
34
/**
35
 * Entry point to set up the {@link \Symfony\Component\Serializer\Serializer Symfony Serializer component}
36
 * for the Experience API.
37
 *
38
 * @author Christian Flothmann <[email protected]>
39
 */
40
class Serializer
41
{
42
    /**
43
     * Creates a new Serializer.
44
     *
45
     * @return SerializerInterface The Serializer
46
     */
47 324
    public static function createSerializer()
48
    {
49
        $normalizers = array(
50 324
            new ActorNormalizer(),
51 324
            new ContextNormalizer(),
52 324
            new ContextActivitiesNormalizer(),
53 324
            new DefinitionNormalizer(),
54 324
            new DocumentDataNormalizer(),
55 324
            new ExtensionsNormalizer(),
56 324
            new LanguageMapNormalizer(),
57 324
            new ObjectNormalizer(),
58 324
            new ResultNormalizer(),
59 324
            new StatementNormalizer(),
60 324
            new StatementResultNormalizer(),
61 324
            new TimestampNormalizer(),
62 324
            new VerbNormalizer(),
63 324
            new ArrayDenormalizer(),
64 324
            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...
65 324
            new PropertyNormalizer(),
66
        );
67
        $encoders = array(
68 324
            new JsonEncoder(),
69
        );
70
71 324
        return new SymfonySerializer($normalizers, $encoders);
72
    }
73
}
74