Code Duplication    Length = 40-40 lines in 2 locations

src/Serialize/Serializer/JmsSerializerAdapter.php 1 location

@@ 19-58 (lines=40) @@
16
 *
17
 * @author John Kleijn <[email protected]>
18
 */
19
class JmsSerializerAdapter implements Serializer
20
{
21
    /**
22
     * @var JmsSerializer
23
     */
24
    private $target;
25
26
    /**
27
     * JmsSerializerAdapter constructor.
28
     *
29
     * @param JmsSerializer $target
30
     */
31
    public function __construct(JmsSerializer $target)
32
    {
33
        $this->target = $target;
34
    }
35
36
    /**
37
     * @param mixed $data any data
38
     *
39
     * @return string
40
     */
41
    public function serialize($data): string
42
    {
43
        return $this->target->serialize($data, 'json');
44
    }
45
46
    /**
47
     * Deserializes data into the given type.
48
     *
49
     * @param mixed  $data
50
     * @param string $type
51
     *
52
     * @return object|array
53
     */
54
    public function deserialize($data, string $type)
55
    {
56
        return $this->target->deserialize($data, $type, 'json');
57
    }
58
}
59

src/Serialize/Serializer/SymfonySerializerAdapter.php 1 location

@@ 20-59 (lines=40) @@
17
 *
18
 * @author John Kleijn <[email protected]>
19
 */
20
class SymfonySerializerAdapter implements Serializer
21
{
22
    /**
23
     * @var SymfonySerializer
24
     */
25
    private $target;
26
27
    /**
28
     * JmsSerializerAdapter constructor.
29
     *
30
     * @param SymfonySerializer $target
31
     */
32
    public function __construct(SymfonySerializer $target)
33
    {
34
        $this->target = $target;
35
    }
36
37
    /**
38
     * @param mixed $data any data
39
     *
40
     * @return string
41
     */
42
    public function serialize($data): string
43
    {
44
        return $this->target->serialize($data, 'json');
45
    }
46
47
    /**
48
     * Deserializes data into the given type.
49
     *
50
     * @param mixed  $data
51
     * @param string $type
52
     *
53
     * @return object|array
54
     */
55
    public function deserialize($data, string $type)
56
    {
57
        return $this->target->deserialize($data, $type, 'json');
58
    }
59
}
60