Passed
Push — master ( eda005...2d3321 )
by Andrey
02:01
created

ResourceListController::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 14
nc 1
nop 2
dl 0
loc 19
rs 9.7998
c 0
b 0
f 0
ccs 14
cts 14
cp 1
crap 1
1
<?php
2
3
namespace JDesrosiers\Silex\Provider;
4
5
use Silex\Application;
6
use Symfony\Component\HttpFoundation\Request;
7
use Symfony\Component\HttpFoundation\Response;
8
9
class ResourceListController
10
{
11
    /**
12
     * Route for GETting the resource list
13
     *
14
     * @param Application $app
15
     * @param Request $request
16
     *
17
     * @return Response
18
     */
19 12
    public function __invoke(Application $app, Request $request)
20
    {
21
        $options = array(
22 12
            "output" => "json",
23 12
            "json_pretty_print" => $app["swagger.prettyPrint"],
24 12
            'basePath' => $app["swagger.basePath"],
25 12
            "prefix" => $app["swagger.resourcePrefix"],
26 12
            "suffix" => $app["swagger.resourceSuffix"],
27 12
            "apiVersion" => $app["swagger.apiVersion"],
28 12
            "swaggerVersion" => $app["swagger.swaggerVersion"],
29
        );
30 12
        $json = $app["swagger"]->getResourceList($options);
31
32 11
        $response = Response::create($json, 200, array("Content-Type" => "application/json"));
33 11
        $response->setCache($app["swagger.cache"]);
34 11
        $response->setEtag(md5($json));
35 11
        $response->isNotModified($request);
36
37 11
        return $response;
38
    }
39
}