Failed Conditions
Push — experimental/3.1 ( 2823d3...342757 )
by Yangsin
85:33
created

EntityFormController::index()   B

Complexity

Conditions 3
Paths 2

Size

Total Lines 31
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 14
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 31
rs 8.8571
1
<?php
2
namespace Acme\Controller;
3
4
use Eccube\Application;
5
use Eccube\Entity\BaseInfo;
6
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
7
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
8
use Symfony\Component\HttpFoundation\Request;
9
10
class EntityFormController
0 ignored issues
show
introduced by
Missing class doc comment
Loading history...
11
{
12
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$app" missing
Loading history...
introduced by
Doc comment for parameter "$request" missing
Loading history...
13
     * @Route("/entity-form")
14
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
15
    public function index(Application $app, Request $request)
16
    {
17
        $BaseInfo = new BaseInfo();
18
19
        $builder = $app->form(
20
            $BaseInfo,
21
            [
22
                'data_class' => BaseInfo::class,
23
            ]
24
        );
25
26
        $form = $builder->getForm();
27
        $form->add('submit', SubmitType::class);
28
29
        $form->handleRequest($request);
30
        if ($form->isSubmitted() && $form->isValid()) {
0 ignored issues
show
Unused Code introduced by
This if statement is empty and can be removed.

This check looks for the bodies of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These if bodies can be removed. If you have an empty if but statements in the else branch, consider inverting the condition.

if (rand(1, 6) > 3) {
//print "Check failed";
} else {
    print "Check succeeded";
}

could be turned into

if (rand(1, 6) <= 3) {
    print "Check succeeded";
}

This is much more concise to read.

Loading history...
31
            // do stuff.
32
        }
33
34
        $template = "
35
            {{ form_start(form) }}
36
            {{ form_row(form) }}
37
            {{ form_end(form) }}
38
        ";
39
40
        $params = ['form' => $form->createView()];
41
42
        return $app['twig']
43
            ->createTemplate($template)
44
            ->render($params);
45
    }
46
}