Completed
Push — master ( df9952...f86661 )
by Hannes
04:17 queued 02:11
created

JsonDecoder   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 18
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A encode() 0 4 1
A decode() 0 4 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace hanneskod\yaysondb\Engine;
6
7
/**
8
 * Decoder for the json format
9
 */
10
class JsonDecoder implements DecoderInterface
11
{
12
    /**
13
     * Encode content to json
14
     */
15
    public function encode(array $content): string
16
    {
17
        return json_encode($content, JSON_PRETTY_PRINT);
18
    }
19
20
    /**
21
     * Decode json content
22
     */
23
    public function decode(string $source): array
24
    {
25
        return (array)json_decode($source, true);
26
    }
27
}
28