Gzip::serialize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
/**
3
 * For the full copyright and license information, please view the LICENSE
4
 * file that was distributed with this source code.
5
 *
6
 * @author Igor Borodikhin <[email protected]>
7
 * @license MIT
8
 */
9
namespace Endeveit\Cache\Serializers;
10
11
use Endeveit\Cache\Interfaces\Serializer;
12
13
/**
14
 * Serializer that compresses data with gzip.
15
 */
16
class Gzip implements Serializer
17
{
18
19
    /**
20
     * {@inheritdoc}
21
     *
22
     * @param  mixed  $value
23
     * @return string
24
     */
25
    public function serialize($value)
26
    {
27
        return gzdeflate(serialize($value));
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     *
33
     * @param  string $str
34
     * @return mixed
35
     */
36
    public function unserialize($str)
37
    {
38
        return unserialize(gzinflate($str));
39
    }
40
}
41