Completed
Push — master ( 664783...554f9d )
by
unknown
15:59
created

DefaultController   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 4
dl 0
loc 56
ccs 0
cts 27
cp 0
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A indexAction() 0 6 1
A optionsAction() 0 7 1
A serviceAction() 0 6 1
A serviceSchemaAction() 0 6 1
1
<?php
2
/**
3
 * Entry point controller.
4
 */
5
namespace Graviton\AnalyticsBundle\Controller;
6
7
use Graviton\AnalyticsBundle\Manager\ServiceManager;
8
use Symfony\Component\HttpFoundation\JsonResponse;
9
use Symfony\Component\HttpFoundation\Response;
10
11
/**
12
 * @author   List of contributors <https://github.com/libgraviton/graviton/graphs/contributors>
13
 * @license  http://opensource.org/licenses/gpl-license.php GNU Public License
14
 * @link     http://swisscom.ch
15
 */
16
class DefaultController
17
{
18
    /** @var ServiceManager */
19
    private $serviceManager;
20
21
    /**
22
     * DefaultController constructor.
23
     * @param ServiceManager $serviceManager Parsing the requested date
24
     */
25
    public function __construct(
26
        ServiceManager $serviceManager
27
    ) {
28
        $this->serviceManager = $serviceManager;
29
    }
30
31
    /**
32
     * @return JsonResponse
33
     */
34
    public function indexAction()
35
    {
36
        $data = $this->serviceManager->getServices();
37
38
        return new JsonResponse($data);
39
    }
40
41
    /**
42
     * @return Response
43
     */
44
    public function optionsAction()
45
    {
46
        $resp = new Response();
47
        $resp->setStatusCode(Response::HTTP_NO_CONTENT);
48
        $resp->headers->set("Access-Control-Allow-Methods", "GET, OPTIONS");
49
        return $resp;
50
    }
51
52
    /**
53
     * @return JsonResponse
54
     */
55
    public function serviceAction()
56
    {
57
        $data = $this->serviceManager->getData();
58
59
        return new JsonResponse($data);
60
    }
61
62
    /**
63
     * @return JsonResponse
64
     */
65
    public function serviceSchemaAction()
66
    {
67
        $data = $this->serviceManager->getSchema();
68
69
        return new JsonResponse($data);
70
    }
71
}
72