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