Completed
Push — 2.0 ( 323339...793d84 )
by Hannes
01:12
created

FlatJsonDecoder   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A encode() 0 10 2
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace hanneskod\yaysondb\Engine;
6
7
use hanneskod\yaysondb\Exception\RuntimeException;
8
9
class FlatJsonDecoder extends JsonDecoder
10
{
11
    public function encode(array $content): string
12
    {
13
        $json = json_encode($content);
14
15
        if (!$json) {
16
            throw new RuntimeException("Unable to encode malformed content");
17
        }
18
19
        return $json;
20
    }
21
}
22