Completed
Push — master ( 8cdbfc...fd3d59 )
by Christian
04:54 queued 02:01
created

SerializerFactory   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 5
dl 0
loc 41
ccs 0
cts 20
cp 0
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 2
A createStatementSerializer() 0 4 1
A createStatementResultSerializer() 0 4 1
A createActorSerializer() 0 4 1
A createDocumentDataSerializer() 0 4 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\SerializerInterface;
15
use Xabbuh\XApi\Serializer\SerializerFactoryInterface;
16
17
/**
18
 * Creates serializer instances that use the Symfony Serializer component.
19
 *
20
 * @author Christian Flothmann <[email protected]>
21
 */
22
final class SerializerFactory implements SerializerFactoryInterface
23
{
24
    private $serializer;
25
26
    public function __construct(SerializerInterface $serializer = null)
27
    {
28
        $this->serializer = $serializer ?: Serializer::createSerializer();
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function createStatementSerializer()
35
    {
36
        return new StatementSerializer($this->serializer);
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function createStatementResultSerializer()
43
    {
44
        return new StatementResultSerializer($this->serializer);
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    public function createActorSerializer()
51
    {
52
        return new ActorSerializer($this->serializer);
53
    }
54
55
    /**
56
     * {@inheritdoc}
57
     */
58
    public function createDocumentDataSerializer()
59
    {
60
        return new DocumentDataSerializer($this->serializer);
61
    }
62
}
63