Passed
Push — master ( 0b0ee1...9503f0 )
by Petr
06:38 queued 03:11
created

Json::unpack()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 2
rs 10
1
<?php
2
3
namespace kalanis\kw_forms\Cache\Formats;
4
5
6
use kalanis\kw_forms\Interfaces\ICachedFormat;
7
8
9
/**
10
 * Class Json
11
 * @package kalanis\kw_forms\Cache\Formats
12
 */
13
class Json implements ICachedFormat
14
{
15 1
    public function pack(array $data): string
16
    {
17 1
        return strval(json_encode($data));
18
    }
19
20 1
    public function unpack(string $content): array
21
    {
22 1
        $data = @ json_decode($content, true);
23 1
        return (false === $data) ? [] : $data ;
24
    }
25
}
26