Passed
Pull Request — master (#36)
by Rogier
01:35
created

json_validate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 2
c 1
b 1
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
if (!function_exists('value')) {
4
    /**
5
     * Return the default value of the given value.
6
     *
7
     * @param mixed $value
8
     *
9
     * @return mixed
10
     */
11
    function value($value)
12
    {
13
        return $value instanceof Closure ? $value() : $value;
14
    }
15
}
16
17
if (!function_exists('json_validate')) {
18
    function json_validate(string $json): bool
19
    {
20
        json_decode($json);
21
22
        return json_last_error() === JSON_ERROR_NONE;
23
    }
24
}
25