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

FlatJsonDecoder::encode()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 1
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