Code Duplication    Length = 16-16 lines in 2 locations

src/CouchDB/Encoder/JSONEncoder.php 2 locations

@@ 17-32 (lines=16) @@
14
    {
15
    }
16
17
    public static function encode($value)
18
    {
19
        set_error_handler(function () use ($value) {
20
            throw new JsonEncodeException($value);
21
        });
22
23
        $json = json_encode($value);
24
25
        if ('null' === $json && $value !== null) {
26
            throw new JsonEncodeException($value);
27
        }
28
29
        restore_error_handler();
30
31
        return $json;
32
    }
33
34
    public static function decode($json)
35
    {
@@ 34-49 (lines=16) @@
31
        return $json;
32
    }
33
34
    public static function decode($json)
35
    {
36
        set_error_handler(function () use ($json) {
37
            throw new JsonDecodeException($json);
38
        });
39
40
        $value = json_decode($json, true);
41
42
        if (false === $value) {
43
            throw new JsonDecodeException($json);
44
        }
45
46
        restore_error_handler();
47
48
        return $value;
49
    }
50
}
51