Completed
Pull Request — master (#18)
by Dominik
05:16
created

NativeJsonParser   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A parse() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chubbyphp\Deserialization\Decoder\Parsing;
6
7
final class NativeJsonParser implements JsonParserInterface
8
{
9
    /**
10
     * @param string $json
11
     * @return array|string|float|int|bool|null
12
     * @throws JsonParserException
13
     */
14
    public function parse(string $json)
15
    {
16
        $data = json_decode($json, true);
17
18
        if (JSON_ERROR_NONE !== json_last_error()) {
19
            throw JsonParserException::createFromError(json_last_error_msg());
20
        }
21
22
        return $data;
23
    }
24
}
25