PhpSerializer   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
4
namespace Retrinko\Serializer\Serializers;
5
6
7
/**
8
 * Class PhpSerializer
9
 * @package Retrinko\Serializer\Serializers
10
 */
11
class PhpSerializer extends AbstractSerializer
12
{
13
14
    /**
15
     * Serialized content type.
16
     * type/lang[/serizalizationFunctions]
17
     */
18
    const SERIALIZED_CONTENT_TYPE = 'application/php/serialize/base64_encode';
19
20
    /**
21
     * @param mixed $input
22
     * @return string
23
     */
24 1
    public function serialize($input)
25
    {
26 1
        return base64_encode(serialize($input));
27
    }
28
29
    /**
30
     * @param $input
31
     * @return mixed
32
     */
33 1
    public function unserialize($input)
34
    {
35 1
        return unserialize(base64_decode($input));
36
    }
37
38
    /**
39
     * @return string
40
     */
41 1
    public function getSerializedContentType()
42
    {
43 1
        return self::SERIALIZED_CONTENT_TYPE;
44
    }
45
}