Conditions | 1 |
Paths | 1 |
Total Lines | 56 |
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 |
||
17 | public function testLoadDefault(): void |
||
18 | { |
||
19 | $this->load([ |
||
20 | 'groups' => [ |
||
21 | 'test' => [ |
||
22 | 'name' => 'FooMenu', |
||
23 | 'attributes' => [ |
||
24 | 'class' => 'my-class', |
||
25 | ], |
||
26 | 'items' => [ |
||
27 | 'foo' => [ |
||
28 | 'label' => 'my-label', |
||
29 | ], |
||
30 | 'bar' => [ |
||
31 | 'label' => 'my-other-label', |
||
32 | 'icon' => 'fa fa-home', |
||
33 | 'route' => 'my-route', |
||
34 | 'routeParams' => ['foo' => 'bar'], |
||
35 | ], |
||
36 | ], |
||
37 | ], |
||
38 | ], |
||
39 | ]); |
||
40 | |||
41 | $this->assertContainerBuilderHasService('core23_menu.builder.config'); |
||
42 | $this->assertContainerBuilderHasService('core23_menu.config_provider'); |
||
43 | |||
44 | $this->assertContainerBuilderHasParameter('core23_menu.groups', [ |
||
45 | 'static_test' => [ |
||
46 | 'name' => 'FooMenu', |
||
47 | 'attributes' => [ |
||
48 | 'class' => 'my-class', |
||
49 | ], |
||
50 | 'items' => [ |
||
51 | 'foo' => [ |
||
52 | 'label' => 'my-label', |
||
53 | 'label_catalogue' => false, |
||
54 | 'icon' => null, |
||
55 | 'class' => null, |
||
56 | 'route' => null, |
||
57 | 'routeParams' => [], |
||
58 | 'children' => [], |
||
59 | ], |
||
60 | 'bar' => [ |
||
61 | 'label' => 'my-other-label', |
||
62 | 'icon' => 'fa fa-home', |
||
63 | 'route' => 'my-route', |
||
64 | 'routeParams' => ['foo' => 'bar'], |
||
65 | 'label_catalogue' => false, |
||
66 | 'class' => null, |
||
67 | 'children' => [], |
||
68 | ], |
||
69 | ], |
||
70 | ], |
||
71 | ]); |
||
72 | } |
||
73 | |||
81 |