Conditions | 1 |
Paths | 1 |
Total Lines | 69 |
Code Lines | 53 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
108 | public function testGetWidgets() |
||
109 | { |
||
110 | $this->collector->collect(); |
||
111 | $result = $this->collector->getWidgets(); |
||
112 | // Stub out the dynamic data |
||
113 | $result['version']['tooltip'] = 'Stub'; |
||
114 | $result['locale']['tooltip'] = 'Stub'; |
||
115 | $result['user']['tooltip'] = 'Current member'; |
||
116 | |||
117 | $expected = array( |
||
118 | 'user' => array( |
||
119 | 'icon' => 'user', |
||
120 | 'tooltip' => 'Current member', |
||
121 | 'default' => '', |
||
122 | ), |
||
123 | 'version' => array( |
||
124 | 'icon' => 'desktop', |
||
125 | 'tooltip' => 'Stub', |
||
126 | 'default' => '', |
||
127 | ), |
||
128 | 'locale' => array( |
||
129 | 'icon' => 'globe', |
||
130 | 'tooltip' => 'Stub', |
||
131 | 'default' => '', |
||
132 | ), |
||
133 | 'session' => array( |
||
134 | 'icon' => 'archive', |
||
135 | 'widget' => 'PhpDebugBar.Widgets.VariableListWidget', |
||
136 | 'map' => 'silverstripe.session', |
||
137 | 'default' => '{}', |
||
138 | ), |
||
139 | 'cookies' => array( |
||
140 | 'icon' => 'asterisk', |
||
141 | 'widget' => 'PhpDebugBar.Widgets.VariableListWidget', |
||
142 | 'map' => 'silverstripe.cookies', |
||
143 | 'default' => '{}', |
||
144 | ), |
||
145 | 'parameters' => array( |
||
146 | 'icon' => 'arrow-right', |
||
147 | 'widget' => 'PhpDebugBar.Widgets.VariableListWidget', |
||
148 | 'map' => 'silverstripe.parameters', |
||
149 | 'default' => '{}', |
||
150 | ), |
||
151 | 'SiteConfig' => array( |
||
152 | 'icon' => 'gear', |
||
153 | 'widget' => 'PhpDebugBar.Widgets.VariableListWidget', |
||
154 | 'map' => 'silverstripe.config', |
||
155 | 'default' => '{}', |
||
156 | ), |
||
157 | 'requirements' => array( |
||
158 | 'icon' => 'file-o ', |
||
159 | 'widget' => 'PhpDebugBar.Widgets.ListWidget', |
||
160 | 'map' => 'silverstripe.requirements', |
||
161 | 'default' => '{}', |
||
162 | ), |
||
163 | 'templates' => array( |
||
164 | 'icon' => 'edit', |
||
165 | 'widget' => 'PhpDebugBar.Widgets.ListWidget', |
||
166 | 'map' => "silverstripe.templates.templates", |
||
167 | 'default' => '{}' |
||
168 | ), |
||
169 | 'templates:badge' => array( |
||
170 | 'map' => 'silverstripe.templates.count', |
||
171 | 'default' => 0 |
||
172 | ) |
||
173 | ); |
||
174 | |||
175 | $this->assertSame($expected, $result); |
||
176 | } |
||
177 | |||
187 |