Completed
Push — master ( 6dd36b...4e0b95 )
by Christian
02:36
created

Serializer   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 10

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 1
c 2
b 0
f 0
lcom 0
cbo 10
dl 0
loc 26
ccs 11
cts 11
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A createSerializer() 0 18 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\DocumentDataNormalizer;
21
use Xabbuh\XApi\Serializer\Normalizer\ObjectNormalizer;
22
use Xabbuh\XApi\Serializer\Normalizer\ResultNormalizer;
23
use Xabbuh\XApi\Serializer\Normalizer\StatementNormalizer;
24
use Xabbuh\XApi\Serializer\Normalizer\StatementResultNormalizer;
25
26
/**
27
 * Entry point to setup the {@link \Symfony\Component\Serializer\Serializer Symfony Serializer component}
28
 * for the Experience API.
29
 *
30
 * @author Christian Flothmann <[email protected]>
31
 */
32
class Serializer
33
{
34
    /**
35
     * Creates a new Serializer.
36
     *
37
     * @return SerializerInterface The Serializer
38
     */
39 24
    public static function createSerializer()
40
    {
41
        $normalizers = array(
42 24
            new ActorNormalizer(),
43 24
            new DocumentDataNormalizer(),
44 24
            new ObjectNormalizer(),
45 24
            new ResultNormalizer(),
46 24
            new StatementNormalizer(),
47 24
            new StatementResultNormalizer(),
48 24
            new ArrayDenormalizer(),
49 24
            new PropertyNormalizer(),
50
        );
51
        $encoders = array(
52 24
            new JsonEncoder(),
53
        );
54
55 24
        return new SymfonySerializer($normalizers, $encoders);
56
    }
57
}
58