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

ResourceListController   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 29
rs 10
c 0
b 0
f 0
ccs 14
cts 14
cp 1
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 19 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
}