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.

SchemaControllerProvider::connect()   A
last analyzed

Complexity

Conditions 3
Paths 1

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 9.6333
c 0
b 0
f 0
cc 3
nc 1
nop 1
ccs 12
cts 12
cp 1
crap 3
1
<?php
2
3
namespace JDesrosiers\Resourceful\SchemaControllerProvider;
4
5
use JDesrosiers\Resourceful\Controller\GetResourceController;
6
use Silex\Api\ControllerProviderInterface;
7
use Silex\Application;
8
use Symfony\Component\HttpFoundation\Request;
9
use Symfony\Component\HttpFoundation\Response;
10
11
class SchemaControllerProvider implements ControllerProviderInterface
12
{
13 9
    public function connect(Application $app)
14
    {
15 9
        $resource = $app["controllers_factory"];
16
17 9
        $resource->get("/{type}", new GetResourceController($app["resourceful.schemas"], "application/schema+json"))
18 9
            ->assert("type", ".+")
19 9
            ->bind("schema");
20
21 9
        $resource->after(function (Request $request, Response $response, Application $app) {
22 3
            if ($response->isSuccessful()) {
23 2
                $schema = json_decode($response->getContent(), true);
24 2
                $app["json-schema.describedBy"] = array_key_exists('$schema', $schema)
25 1
                    ? $schema['$schema']
26 1
                    : $app["resourceful.defaultSchemaVersion"];
27
            }
28 9
        });
29
30
        return $resource;
31
    }
32
}
33