Completed
Pull Request — master (#17)
by Luc
08:31 queued 05:35
created

QuestionViewController   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
dl 0
loc 53
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 10 2
A __construct() 0 6 1
A index() 0 8 2
1
<?php declare(strict_types=1);
2
3
namespace VSV\GVQ_API\Question\Controllers;
4
5
use function GuzzleHttp\Promise\all;
6
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
7
use Symfony\Component\HttpFoundation\Request;
8
use Symfony\Component\HttpFoundation\Response;
9
use VSV\GVQ_API\Factory\ModelsFactory;
10
use VSV\GVQ_API\Question\Repositories\CategoryRepository;
11
use VSV\GVQ_API\Question\Repositories\QuestionRepository;
12
13
class QuestionViewController extends AbstractController
14
{
15
    /**
16
     * @var QuestionRepository
17
     */
18
    private $questionRepository;
19
20
    /**
21
     * @var CategoryRepository
22
     */
23
    private $categoryRepository;
24
25
    /**
26
     * @param QuestionRepository $questionRepository
27
     * @param CategoryRepository $categoryRepository
28
     */
29
    public function __construct(
30
        QuestionRepository $questionRepository,
31
        CategoryRepository $categoryRepository
32
    ) {
33
        $this->questionRepository = $questionRepository;
34
        $this->categoryRepository = $categoryRepository;
35
    }
36
37
    /**
38
     * @return Response
39
     */
40
    public function index(): Response
41
    {
42
        $questions = $this->questionRepository->getAll();
43
44
        return $this->render(
45
            'questions/index.html.twig',
46
            [
47
                'questions' => $questions ? $questions->toArray() : [],
48
            ]
49
        );
50
    }
51
52
    /**
53
     * @param Request $request
54
     * @return Response
55
     */
56
    public function add(Request $request): Response
57
    {
58
        var_dump($request->request->all());
0 ignored issues
show
Security Debugging Code introduced by
var_dump($request->request->all()) looks like debug code. Are you sure you do not want to remove it?
Loading history...
59
        var_dump($request->files);
60
61
        $categories = $this->categoryRepository->getAll();
62
        return $this->render(
63
            'questions/add.html.twig',
64
            [
65
                'categories' => $categories ? $categories->toArray() : [],
66
            ]
67
        );
68
    }
69
}
70