Completed
Push — master ( f1dd26...2cc827 )
by Dmitri
03:03
created

DatetimeController   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 53
Duplicated Lines 100 %

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A indexAction() 8 8 1
A addonForm() 8 8 1
A defaultForm() 13 13 1
A inlineForm() 7 7 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace AppBundle\Controller;
4
5
use Devmachine\Bundle\FormBundle\Form\Type\DateTimeType;
6
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
0 ignored issues
show
Bug introduced by
The type Sensio\Bundle\FrameworkE...dle\Configuration\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...
7
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
0 ignored issues
show
Bug introduced by
The type Sensio\Bundle\FrameworkE...\Configuration\Template 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
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
9
10 View Code Duplication
class DatetimeController extends Controller
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...
11
{
12
    use ServicesTrait;
13
14
    /**
15
     * @Route("/", name="datetime")
16
     * @Template("AppBundle::datetime.html.twig")
17
     */
18
    public function indexAction()
19
    {
20
        return [
21
            'default' => $this->defaultForm()->createView(),
22
            'inline'  => $this->inlineForm()->createView(),
23
            'addon'   => $this->addonForm()->createView(),
24
            'title'   => 'Bootstrap datetime',
25
            'nav'     => 'datetime',
26
        ];
27
    }
28
29
    private function defaultForm()
30
    {
31
        return $this->createNamedBuilder('default')
32
            ->add('datetime', DateTimeType::class, [
33
                'config' => [
34
                    'calendarWeeks'   => true,
35
                    'showTodayButton' => true,
36
                    'showClear'       => true,
37
                    'showClose'       => true,
38
                ],
39
                'format' => 'dd/MM/y HH:mm',
40
            ])
41
            ->getForm()
42
        ;
43
    }
44
45
    private function addonForm()
46
    {
47
        return $this->createNamedBuilder('addon')
48
            ->add('datetime', DateTimeType::class, [
49
                'input_addon' => true,
50
                'locale'      => 'ru',
51
            ])
52
            ->getForm()
53
        ;
54
    }
55
56
    private function inlineForm()
57
    {
58
        return $this->createNamedBuilder('inline')
59
            ->add('datetime', DateTimeType::class, [
60
                'inline' => true,
61
            ])
62
            ->getForm()
63
        ;
64
    }
65
}
66