Completed
Push — master ( 9c5fdf...27a5d2 )
by John
7s
created

JmsSerializerAdapter::deserialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 3
1
<?php declare(strict_types = 1);
2
/*
3
 * This file is part of the KleijnWeb\SwaggerBundle package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace KleijnWeb\SwaggerBundle\Serialize\Serializer;
10
11
use JMS\Serializer\SerializerInterface as JmsSerializer;
12
use KleijnWeb\SwaggerBundle\Document\Specification;
13
use KleijnWeb\SwaggerBundle\Serialize\Serializer;
14
15
/**
16
 * Adapter for JMS\Serializer
17
 *
18
 * @author John Kleijn <[email protected]>
19
 */
20 View Code Duplication
class JmsSerializerAdapter implements Serializer
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...
21
{
22
    /**
23
     * @var JmsSerializer
24
     */
25
    private $target;
26
27
    /**
28
     * JmsSerializerAdapter constructor.
29
     *
30
     * @param JmsSerializer $target
31
     */
32
    public function __construct(JmsSerializer $target)
33
    {
34
        $this->target = $target;
35
    }
36
37
    /**
38
     * @param mixed         $data any data
39
     * @param Specification $specification
40
     *
41
     * @return string
42
     */
43
    public function serialize($data, Specification $specification): string
44
    {
45
        return $this->target->serialize($data, 'json');
46
    }
47
48
    /**
49
     * Deserializes data into the given type.
50
     *
51
     * @param mixed         $data
52
     * @param string        $type
53
     * @param Specification $specification
54
     *
55
     * @return array|object
56
     */
57
    public function deserialize($data, string $type, Specification $specification)
58
    {
59
        return $this->target->deserialize($data, $type, 'json');
60
    }
61
}
62