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.

SwaggerProvider::register()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
nc 1
nop 3
dl 0
loc 13
ccs 0
cts 13
cp 0
crap 6
rs 9.8333
c 0
b 0
f 0
1
<?php
2
namespace PhpBoot\Docgen\Swagger;
3
4
use PhpBoot\Application;
5
use Symfony\Component\HttpFoundation\Response;
6
7
class SwaggerProvider
8
{
9
    /**
10
     * How to use
11
     *
12
     * SwaggerProvider::register($app, function(Swagger $swagger){
13
     *          $swagger->host = 'api.example.com',
14
     *          $swagger->info->description = '...';
15
     *          ...
16
     *      },
17
     *      '/docs')
18
     *
19
     * @param Application $app
20
     * @param string $prefix
21
     * @param callable $callback
22
     * @return void
23
     */
24
    static public function register(Application $app,
25
                                    callable $callback = null,
26
                                    $prefix='/docs')
27
    {
28
        $app->addRoute('GET', $prefix.'/swagger.json', function (Application $app)use($callback){
29
            $swagger = new Swagger();
30
            $swagger->appendControllers($app, $app->getControllers());
31
            if($callback){
32
                $callback($swagger);
33
            }
34
            return new Response($swagger->toJson());
35
        });
36
    }
37
}