Index::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 59
Code Lines 29

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 29
c 1
b 1
f 0
nc 1
nop 28
dl 0
loc 59
rs 9.456

How to fix   Long Method    Many Parameters   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
declare(strict_types=1);
4
5
namespace LAG\AdminBundle\Metadata;
6
7
use LAG\AdminBundle\Bridge\Doctrine\ORM\State\ORMDataProcessor;
8
use LAG\AdminBundle\Bridge\Doctrine\ORM\State\ORMDataProvider;
9
10
class Index extends CollectionOperation
11
{
12
    public function __construct(
13
        ?string $name = 'index',
14
        ?string $title = null,
15
        ?string $description = null,
16
        ?string $icon = null,
17
        ?string $template = '@LAGAdmin/crud/index.html.twig',
18
        array $permissions = [],
19
        ?string $controller = \LAG\AdminBundle\Controller\Index::class,
20
        ?string $route = null,
21
        array $routeParameters = [],
22
        array $methods = [],
23
        string $path = '',
24
        ?string $targetRoute = null,
25
        array $targetRouteParameters = [],
26
        array $properties = [],
27
        ?string $formType = null,
28
        array $formOptions = [],
29
        string $processor = ORMDataProcessor::class,
30
        string $provider = ORMDataProvider::class,
31
        array $identifiers = ['id'],
32
        ?array $contextualActions = null,
33
        ?array $itemActions = null,
34
        bool $pagination = true,
35
        int $itemPerPage = 25,
36
        string $pageParameter = 'page',
37
        array $criteria = [],
38
        array $orderBy = [],
39
        ?array $filters = null,
40
        ?string $gridTemplate = '@LAGAdmin/grid/table_grid.html.twig',
41
    ) {
42
        parent::__construct(
43
            $name,
44
            $title,
45
            $description,
46
            $icon,
47
            $template,
48
            $permissions,
49
            $controller,
50
            $route,
51
            $routeParameters,
52
            $methods,
53
            $path,
54
            $targetRoute,
55
            $targetRouteParameters,
56
            $properties,
57
            $formType,
58
            $formOptions,
59
            $processor,
60
            $provider,
61
            $identifiers,
62
            $contextualActions,
63
            $itemActions,
64
            $pagination,
65
            $itemPerPage,
66
            $pageParameter,
67
            $criteria,
68
            $orderBy,
69
            $filters,
70
            $gridTemplate,
71
        );
72
    }
73
}
74