JsonSerializer   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 37
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A serialize() 0 4 1
A unserialize() 0 4 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