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

Json::pack()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

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
ccs 2
cts 2
cp 1
crap 1
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