Conditions | 1 |
Paths | 1 |
Total Lines | 102 |
Code Lines | 68 |
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 |
||
146 | public function getApplicableDiffProvider() { |
||
147 | // Diff, current object, expected |
||
148 | $argLists = array(); |
||
149 | |||
150 | $diff = new Diff( array(), false ); |
||
151 | $currentObject = array(); |
||
152 | $expected = clone $diff; |
||
153 | |||
154 | $argLists[] = array( $diff, $currentObject, $expected, 'Empty diff should remain empty on empty base' ); |
||
155 | |||
156 | $diff = new Diff( array(), false ); |
||
157 | |||
158 | $currentObject = array( 'foo' => 0, 'bar' => 1 ); |
||
159 | |||
160 | $expected = clone $diff; |
||
161 | |||
162 | $argLists[] = array( $diff, $currentObject, $expected, 'Empty diff should remain empty on non-empty base' ); |
||
163 | |||
164 | $diff = new Diff( array( |
||
165 | new DiffOpRemove( 9001 ), |
||
166 | ), false ); |
||
167 | |||
168 | $currentObject = array(); |
||
169 | |||
170 | $expected = new Diff( array(), false ); |
||
171 | |||
172 | $argLists[] = array( $diff, $currentObject, $expected, 'Remove ops should be removed on empty base' ); |
||
173 | |||
174 | $diff = new Diff( array( |
||
175 | new DiffOpAdd( 42 ), |
||
176 | new DiffOpRemove( 9001 ), |
||
177 | ), false ); |
||
178 | |||
179 | $currentObject = array(); |
||
180 | |||
181 | $expected = new Diff( array( |
||
182 | new DiffOpAdd( 42 ), |
||
183 | ), true ); |
||
184 | |||
185 | $argLists[] = array( |
||
186 | $diff, |
||
187 | $currentObject, |
||
188 | $expected, |
||
189 | 'Add ops not present in the base should be retained (ListDiff)' |
||
190 | ); |
||
191 | |||
192 | $diff = new Diff( array( |
||
193 | new DiffOpAdd( 42 ), |
||
194 | new DiffOpRemove( 9001 ), |
||
195 | ), false ); |
||
196 | |||
197 | $currentObject = array( 1, 42, 9001 ); |
||
198 | |||
199 | $expected = new Diff( array( |
||
200 | new DiffOpAdd( 42 ), |
||
201 | new DiffOpRemove( 9001 ), |
||
202 | ), false ); |
||
203 | |||
204 | $argLists[] = array( |
||
205 | $diff, |
||
206 | $currentObject, |
||
207 | $expected, |
||
208 | 'Add ops with values present in the base should be retained in ListDiff' |
||
209 | ); |
||
210 | |||
211 | $diff = new Diff( array( |
||
212 | new DiffOpAdd( 42 ), |
||
213 | ), false ); |
||
214 | |||
215 | $currentObject = array(); |
||
216 | |||
217 | $expected = clone $diff; |
||
218 | |||
219 | $argLists[] = array( |
||
220 | $diff, |
||
221 | $currentObject, |
||
222 | $expected, |
||
223 | 'list diffs containing only add ops should be retained even when not in the base' |
||
224 | ); |
||
225 | |||
226 | $diff = new Diff( array( |
||
227 | new DiffOpRemove( 42 ), |
||
228 | new DiffOpRemove( 9001 ), |
||
229 | ), false ); |
||
230 | |||
231 | $currentObject = array( |
||
232 | 42, |
||
233 | 72010, |
||
234 | 9001, |
||
235 | ); |
||
236 | |||
237 | $expected = clone $diff; |
||
238 | |||
239 | $argLists[] = array( |
||
240 | $diff, |
||
241 | $currentObject, |
||
242 | $expected, |
||
243 | 'list diffs containing only remove ops should be retained when present in the base' |
||
244 | ); |
||
245 | |||
246 | return $argLists; |
||
247 | } |
||
248 | |||
261 |