Completed
Push — serialize ( cca242 )
by Michal
02:25
created

Serializer::serialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
/*
3
 * This file is part of the Sift PHP framework.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace ILess\Util;
10
11
final class Serializer
12
{
13
    /**
14
     * Serializes variables.
15
     *
16
     * @param array $vars
17
     *
18
     * @return string
19
     */
20
    public static function serialize($vars)
21
    {
22
        return serialize($vars);
23
    }
24
25
    /**
26
     * @param string $serialized
27
     *
28
     * @return array
29
     */
30
    public static function unserialize($serialized)
31
    {
32
        $unserialized = @unserialize($serialized);
33
        if ($unserialized === false) {
34
            throw new \RuntimeException('Error unserializing serialized data.');
35
        }
36
37
        return $unserialized;
38
    }
39
}
40