Completed
Pull Request — develop (#605)
by
unknown
14:48
created

DefaultController::optionsAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 7
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 7
loc 7
ccs 0
cts 7
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * Entry point controller.
4
 */
5
namespace Graviton\ProxyApiBundle\Controller;
6
7
use Graviton\ProxyApiBundle\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 View Code Duplication
class DefaultController
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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
37
        $data = $this->serviceManager->getServices();
38
39
        return new JsonResponse($data);
40
    }
41
42
    /**
43
     * @return Response
44
     */
45
    public function optionsAction()
46
    {
47
        $resp = new Response();
48
        $resp->setStatusCode(Response::HTTP_NO_CONTENT);
49
        $resp->headers->set("Access-Control-Allow-Methods", "GET, OPTIONS, POST");
50
        return $resp;
51
    }
52
53
    /**
54
     * @return Response
55
     */
56
    public function proxyAction()
57
    {
58
        return $this->serviceManager->processRequest();
59
    }
60
61
    /**
62
     * @return JsonResponse
63
     */
64
    public function schemaAction()
65
    {
66
        $data = $this->serviceManager->getSchema();
0 ignored issues
show
Bug introduced by
The method getSchema() does not seem to exist on object<Graviton\ProxyApi...Manager\ServiceManager>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
67
68
        return new JsonResponse($data);
69
    }
70
}
71