FormController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 2
c 4
b 0
f 0
lcom 1
cbo 4
dl 0
loc 41
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A simpleAction() 0 18 1
A classAction() 0 13 1
1
<?php
2
namespace AppBundle\Controller;
3
4
use AppBundle\Entity\Task;
5
use AppBundle\Form\TaskType;
6
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7
use Symfony\Component\Form\Extension\Core\Type\DateType;
8
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
9
use Symfony\Component\Form\Extension\Core\Type\TextType;
10
use Symfony\Component\HttpFoundation\Request;
11
use Symfony\Component\Routing\Annotation\Route;
12
13
/**
14
 * @Route("/form")
15
 */
16
class FormController extends Controller
17
{
18
    /**
19
     * @Route("/simple", name="form_simple")
20
     */
21
    public function simpleAction(Request $request)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
22
    {
23
        $task = new Task();
24
        $task->setTitle('Make it work!');
25
        $task->setDateCreated(new \DateTime());
26
27
        $form = $this->createFormBuilder($task)
28
            ->add('title', TextType::class)
29
            ->add('dateCreated', DateType::class)
30
            ->add('save', SubmitType::class, array('label' => 'Create Task'))
31
            ->getForm();
32
33
        return $this->render(
34
            'form/new.html.twig', array(
35
            'form' => $form->createView(),
36
            )
37
        );
38
    }
39
40
    /**
41
     * @Route("/class", name="form_class")
42
     */
43
    public function classAction(Request $request)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
44
    {
45
        $task = new Task();
46
        $task->setTitle('Make it work!');
47
        
48
        $form = $this->createForm(TaskType::class, $task);
49
50
        return $this->render(
51
            'form/new.html.twig', array(
52
            'form' => $form->createView(),
53
            )
54
        );
55
    }
56
}