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.

JsonLoader::load()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 15
ccs 8
cts 8
cp 1
rs 9.4285
cc 3
eloc 8
nc 3
nop 0
crap 3
1
<?php
2
3
/**
4
 * This file is part of the m1\vars library
5
 *
6
 * (c) m1 <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * @package     m1/vars
12
 * @version     1.1.0
13
 * @author      Miles Croxford <[email protected]>
14
 * @copyright   Copyright (c) Miles Croxford <[email protected]>
15
 * @license     http://github.com/m1/vars/blob/master/LICENSE
16
 * @link        http://github.com/m1/vars/blob/master/README.MD Documentation
17
 */
18
19
namespace M1\Vars\Loader;
20
21
/**
22
 * The json file loader
23
 *
24
 * @since 0.1.0
25
 */
26
class JsonLoader extends AbstractLoader
27
{
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public static $supported = array('json');
32
33
    /**
34
     * {@inheritdoc}
35
     *
36
     * @throws \RunntimeException If the json file fails to load
37
     */
38 4
    public function load()
39
    {
40 4
        $content = json_decode(file_get_contents($this->entity), true);
41
42 4
        if (json_last_error() !== JSON_ERROR_NONE) {
43 1
            $message = function_exists('json_last_error_msg') ? json_last_error_msg() : 'Parse error';
44
45 1
            throw new \RuntimeException(
46 1
                sprintf("'%s' failed to load with the error '%s'", $this->entity, $message)
47
            );
48
        }
49
50 3
        $this->content = $content;
51 3
        return $this;
52
    }
53
}
54