Str::isJson()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace sixlive\Laravel\JsonSchemaAssertions\Support;
4
5
class Str
6
{
7
    /**
8
     * Test to see if a string is json.
9
     *
10
     * @param  string  $string
11
     *
12
     * @return bool
13
     */
14
    public static function isJson($string)
15
    {
16
        json_decode($string);
17
18
        return json_last_error() === JSON_ERROR_NONE;
19
    }
20
}
21