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

ActorSerializer::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 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