JsonSerializer   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 0
cbo 1
dl 0
loc 35
ccs 6
cts 6
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A serialize() 0 4 1
A unserialize() 0 4 1
A getSerializedContentType() 0 4 1
1
<?php
2
3
namespace Retrinko\Serializer\Serializers;
4
5
/**
6
 * Class JsonSerializer
7
 * @package Retrinko\Serializer\Serializers
8
 */
9
class JsonSerializer extends AbstractSerializer
10
{
11
12
    /**
13
     * Serialized content type.
14
     * type/lang[/serizalizationFunctions]
15
     */
16
    const SERIALIZED_CONTENT_TYPE = 'application/json';
17
18
    /**
19
     * @param mixed $input
20
     * @return string
21
     */
22 1
    public function serialize($input)
23
    {
24 1
        return json_encode($input);
25
    }
26
27
    /**
28
     * @param $input
29
     * @return mixed
30
     */
31 1
    public function unserialize($input)
32
    {
33 1
        return json_decode($input, true);
34
    }
35
36
    /**
37
     * @return string
38
     */
39 1
    public function getSerializedContentType()
40
    {
41 1
        return self::SERIALIZED_CONTENT_TYPE;
42
    }
43
}