ActorSerializer::serializeActor()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 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\Symfony;
13
14
use Symfony\Component\Serializer\SerializerInterface;
15
use Xabbuh\XApi\Model\Actor;
16
use Xabbuh\XApi\Serializer\ActorSerializerInterface;
17
18
/**
19
 * Serializes and deserializes {@link Actor actors} using the Symfony Serializer component.
20
 *
21
 * @author Christian Flothmann <[email protected]>
22
 */
23 View Code Duplication
final class ActorSerializer implements ActorSerializerInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
24
{
25
    /**
26
     * @var SerializerInterface
27
     */
28
    private $serializer;
29
30
    public function __construct(SerializerInterface $serializer)
31
    {
32
        $this->serializer = $serializer;
33
    }
34
35
    /**
36
     * {@inheritDoc}
37
     */
38
    public function serializeActor(Actor $actor)
39
    {
40
        return $this->serializer->serialize($actor, 'json');
41
    }
42
43
    /**
44
     * {@inheritDoc}
45
     */
46
    public function deserializeActor($data)
47
    {
48
        return $this->serializer->deserialize($data, 'Xabbuh\XApi\Model\Actor', 'json');
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->serializer->deser...Model\\Actor', 'json'); of type object|array adds the type array to the return on line 48 which is incompatible with the return type declared by the interface Xabbuh\XApi\Serializer\A...rface::deserializeActor of type Xabbuh\XApi\Model\Actor.
Loading history...
49
    }
50
}
51