JsonSerializer::unserialize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace NilPortugues\MessageBus\Serializer;
4
5
use NilPortugues\MessageBus\Serializer\Contracts\Serializer;
6
7
class JsonSerializer implements Serializer
8
{
9
    /** @var \NilPortugues\Serializer\JsonSerializer */
10
    protected $serializer;
11
12
    /**
13
     * JsonSerializer constructor.
14
     */
15
    public function __construct()
16
    {
17
        $this->serializer = new \NilPortugues\Serializer\JsonSerializer();
18
    }
19
20
    /**
21
     * Turns a data structure into a string that can be recovered.
22
     *
23
     * @param mixed $data
24
     *
25
     * @return string
26
     */
27
    public function serialize($data) : string
28
    {
29
        return $this->serializer->serialize($data);
30
    }
31
32
    /**
33
     * Turns string data structure into an usable $data structure.
34
     *
35
     * @param string $data
36
     *
37
     * @return mixed
38
     */
39
    public function unserialize(string $data)
40
    {
41
        return $this->serializer->unserialize($data);
42
    }
43
}
44