FormsController   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 42
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 17 3
A __construct() 0 3 1
1
<?php
2
3
namespace App\Controller\Scenario;
4
5
use App\Service\ScenarioService;
6
use Symfony\Component\HttpFoundation\JsonResponse;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\HttpFoundation\JsonResponse was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\HttpKe...n\NotFoundHttpException was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
9
use Symfony\Component\Routing\Annotation\Route;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Routing\Annotation\Route was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
11
/**
12
 * Class FormsController
13
 */
14
final class FormsController
15
{
16
    /**
17
     * @var \App\Service\ScenarioService
18
     */
19
    private $scenarioService;
20
21
    /**
22
     * Constructor
23
     *
24
     * @param \App\Service\ScenarioService $scenarioService
25
     */
26
    public function __construct(ScenarioService $scenarioService)
27
    {
28
        $this->scenarioService = $scenarioService;
29
    }
30
31
    /**
32
     * Form
33
     *
34
     * @Route(path="/scenarios/{uuid}/forms", methods={"GET"})
35
     * @param string $uuid
36
     * @return \Symfony\Component\HttpFoundation\JsonResponse
37
     * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
38
     */
39
    public function get($uuid)
40
    {
41
        $scenario = $this->scenarioService->getRepository()->findOneBy(['uuid' => $uuid]);
42
43
        if (!$scenario) {
44
            throw new NotFoundHttpException('Scenario not found.');
45
        }
46
47
        $forms = $this->scenarioService->getForms($scenario);
48
49
        foreach ($forms as $key => $value) {
50
            $forms[$key] = $value->toObject();
51
        }
52
53
        $response = new JsonResponse($forms);
54
55
        return $response;
56
    }
57
}
58