Completed
Push — master ( f10197...20a2f9 )
by Mr
02:03
created

Json::isJson()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
namespace DrMVC\Helpers;
4
5
/**
6
 * Class Json for work with JSON objects
7
 * @package DrMVC\Helpers
8
 */
9
class Json
10
{
11
    /**
12
     * Check if input value is valid JSON
13
     *
14
     * @param   mixed $input
15
     * @return  bool
16
     */
17
    public static function isJson($input): bool
18
    {
19
        $test = json_decode($input);
20
        return ($test instanceof \stdClass || \is_array($test));
21
    }
22
}
23