PhpSerializer::unserialize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 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
}