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