Completed
Push — master ( b96965...99f77d )
by Lars
02:12
created

SerializerDefault::unserialize()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 3
cts 4
cp 0.75
rs 9.9666
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2.0625
1
<?php
2
3
declare(strict_types=1);
4
5
namespace voku\cache;
6
7
/**
8
 * SerializerDefault: simple serialize / unserialize
9
 */
10
class SerializerDefault implements iSerializer
11
{
12
    /**
13
     * @var null|array
14
     */
15
    private $unserialize_options;
16
17
    /**
18
     * {@inheritdoc}
19
     */
20 23
    public function serialize($value)
21
    {
22 23
        return \serialize($value);
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28 21
    public function unserialize($value)
29
    {
30 21
        if ($this->unserialize_options !== null) {
31 21
            return \unserialize($value, $this->unserialize_options);
32
        }
33
34
        /** @noinspection UnserializeExploitsInspection */
35
        return \unserialize($value);
36
    }
37
38
    /**
39
     * @param array $options
40
     */
41 44
    public function setUnserializeOptions(array $options)
42
    {
43 44
        $this->unserialize_options = $options;
44 44
    }
45
}
46