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

Json   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 11
ccs 5
cts 5
cp 1
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A unpack() 0 4 2
A pack() 0 3 1
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