Completed
Pull Request — master (#5)
by Christian
10:47 queued 05:51
created

ActorSerializer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 42.86%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 28
ccs 3
cts 7
cp 0.4286
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A serializeActor() 0 4 1
A deserializeActor() 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\Model\Actor;
16
17
/**
18
 * Serialize and deserialize {@link Actor actors}.
19
 *
20
 * @author Christian Flothmann <[email protected]>
21
 */
22
class ActorSerializer implements ActorSerializerInterface
23
{
24
    /**
25
     * @var SerializerInterface
26
     */
27
    private $serializer;
28
29 5
    public function __construct(SerializerInterface $serializer)
30
    {
31 5
        $this->serializer = $serializer;
32 5
    }
33
34
    /**
35
     * {@inheritDoc}
36
     */
37
    public function serializeActor(Actor $actor)
38
    {
39
        return $this->serializer->serialize($actor, 'json');
40
    }
41
42
    /**
43
     * {@inheritDoc}
44
     */
45
    public function deserializeActor($data)
46
    {
47
        return $this->serializer->deserialize($data, 'Xabbuh\XApi\Model\Actor', 'json');
48
    }
49
}
50