Conditions | 1 |
Paths | 1 |
Total Lines | 75 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
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:
If many parameters/temporary variables are present:
1 | <?php |
||
32 | public function testGroupsOptions(): void |
||
33 | { |
||
34 | $processor = new Processor(); |
||
35 | |||
36 | $config = $processor->processConfiguration(new Configuration(), [[ |
||
37 | 'groups' => [ |
||
38 | 'test' => [ |
||
39 | 'name' => 'FooMenu', |
||
40 | 'attributes' => [ |
||
41 | 'class' => 'my-class', |
||
42 | ], |
||
43 | 'items' => [ |
||
44 | 'foo' => [ |
||
45 | 'label' => 'my-label', |
||
46 | 'children' => [ |
||
47 | 'subfoo' => [ |
||
48 | 'label' => 'my-sub-label', |
||
49 | 'route' => 'my-subroute', |
||
50 | ], |
||
51 | ], |
||
52 | ], |
||
53 | 'bar' => [ |
||
54 | 'label' => 'my-other-label', |
||
55 | 'icon' => 'fa fa-home', |
||
56 | 'route' => 'my-route', |
||
57 | 'routeParams' => ['foo' => 'bar'], |
||
58 | ], |
||
59 | ], |
||
60 | ], |
||
61 | ], |
||
62 | ]]); |
||
63 | |||
64 | $expected = [ |
||
65 | 'groups' => [ |
||
66 | 'test' => [ |
||
67 | 'name' => 'FooMenu', |
||
68 | 'attributes' => [ |
||
69 | 'class' => 'my-class', |
||
70 | ], |
||
71 | 'items' => [ |
||
72 | 'foo' => [ |
||
73 | 'label' => 'my-label', |
||
74 | 'children' => [ |
||
75 | 'subfoo' => [ |
||
76 | 'label' => 'my-sub-label', |
||
77 | 'route' => 'my-subroute', |
||
78 | 'label_catalogue' => false, |
||
79 | 'icon' => null, |
||
80 | 'class' => null, |
||
81 | 'routeParams' => [], |
||
82 | 'children' => [], |
||
83 | ], |
||
84 | ], |
||
85 | 'label_catalogue' => false, |
||
86 | 'icon' => null, |
||
87 | 'class' => null, |
||
88 | 'route' => null, |
||
89 | 'routeParams' => [], |
||
90 | ], |
||
91 | 'bar' => [ |
||
92 | 'label' => 'my-other-label', |
||
93 | 'icon' => 'fa fa-home', |
||
94 | 'route' => 'my-route', |
||
95 | 'routeParams' => ['foo' => 'bar'], |
||
96 | 'label_catalogue' => false, |
||
97 | 'class' => null, |
||
98 | 'children' => [], |
||
99 | ], |
||
100 | ], |
||
101 | ], |
||
102 | ], |
||
103 | ]; |
||
104 | |||
105 | static::assertSame($expected, $config); |
||
106 | } |
||
107 | } |
||
108 |