GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

JsonParser::parse()   B
last analyzed

Complexity

Conditions 5
Paths 3

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 5

Importance

Changes 0
Metric Value
dl 0
loc 13
c 0
b 0
f 0
ccs 7
cts 7
cp 1
rs 8.8571
cc 5
eloc 7
nc 3
nop 1
crap 5
1
<?php
2
3
/*
4
 * This file is part of the php-phantomjs.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
namespace JonnyW\PhantomJs\Parser;
10
11
/**
12
 * PHP PhantomJs
13
 *
14
 * @author Jon Wenmoth <[email protected]>
15
 */
16
class JsonParser implements ParserInterface
17
{
18
    /**
19
     * Parse json string into array.
20
     *
21
     * @access public
22
     * @param  string    $data
23
     * @return \stdClass
24
     */
25 56
    public function parse($data)
26
    {
27 56
        if ($data === null || !is_string($data)) {
28 2
            return array();
29
        }
30
31 54
        if (substr($data, 0, 1) !== '{' &&
32 54
            substr($data, 0, 1) !== '[') {
33 1
            return array();
34
        }
35
36 53
        return (array) json_decode($data, true);
37
    }
38
}
39