Encoder::encode()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Tleckie\Async;
4
5
use function base64_decode;
6
use function unserialize;
7
8
/**
9
 * Class Encoder
10
 *
11
 * @package Tleckie\Async
12
 * @author  Teodoro Leckie Westberg <[email protected]>
13
 */
14
class Encoder
15
{
16
    /**
17
     * @param mixed $object
18
     * @return string|null
19
     */
20
    public function encode(mixed $object): ?string
21
    {
22
        return base64_encode(serialize($object));
23
    }
24
25
    /**
26
     * @param string|null $string
27
     * @return mixed
28
     */
29
    public function decode(?string $string): mixed
30
    {
31
        return @unserialize(base64_decode($string));
32
    }
33
}
34