Conditions | 1 |
Paths | 1 |
Total Lines | 57 |
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 |
||
56 | private function addSendersSection(ArrayNodeDefinition $rootNode) |
||
57 | { |
||
58 | $rootNode |
||
59 | ->children() |
||
60 | ->arrayNode('senders') |
||
61 | ->example([ |
||
62 | 'chained_sender' => [ |
||
63 | 'chain' => [ |
||
64 | 'senders' => [ |
||
65 | 'first_sender', |
||
66 | 'second_sender', |
||
67 | ], |
||
68 | ], |
||
69 | ], |
||
70 | 'first_sender' => [ |
||
71 | 'sender' => ['class' => 'SenderClass'], |
||
72 | 'repository' => ['class' => 'RepositoryClass', 'arguments' => []], |
||
73 | ], |
||
74 | 'second_sender' => [ |
||
75 | 'sender' => ['class' => 'SenderClass'], |
||
76 | 'repository' => ['class' => 'RepositoryClass', 'arguments' => []], |
||
77 | ], |
||
78 | ]) |
||
79 | ->isRequired() |
||
80 | ->requiresAtLeastOneElement() |
||
81 | ->useAttributeAsKey('name') |
||
82 | ->arrayPrototype() |
||
83 | ->children() |
||
84 | ->arrayNode('sender') |
||
85 | ->children() |
||
86 | ->scalarNode('class')->isRequired()->end() |
||
87 | ->end() |
||
88 | ->end() |
||
89 | ->arrayNode('repository') |
||
90 | ->children() |
||
91 | ->scalarNode('class')->isRequired()->end() |
||
92 | ->arrayNode('arguments') |
||
93 | ->defaultValue([]) |
||
94 | ->scalarPrototype()->end() |
||
95 | ->end() |
||
96 | ->end() |
||
97 | ->end() |
||
98 | ->end() |
||
99 | ->children() |
||
100 | ->scalarNode('class')->end() |
||
101 | ->arrayNode('chain') |
||
102 | ->children() |
||
103 | ->arrayNode('senders') |
||
104 | ->scalarPrototype()->end() |
||
105 | ->end() |
||
106 | ->end() |
||
107 | ->end() |
||
108 | ->end() |
||
109 | ->end() |
||
110 | ->end() |
||
111 | ->end(); |
||
112 | } |
||
113 | |||
130 |