| Conditions | 1 |
| Paths | 1 |
| Total Lines | 83 |
| Code Lines | 58 |
| 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 |
||
| 25 | public function patchProvider() { |
||
| 26 | $argLists = array(); |
||
| 27 | |||
| 28 | $patcher = new ListPatcher(); |
||
| 29 | $base = array(); |
||
| 30 | $diff = new Diff(); |
||
| 31 | $expected = array(); |
||
| 32 | |||
| 33 | $argLists[] = array( $patcher, $base, $diff, $expected ); |
||
| 34 | |||
| 35 | $patcher = new ListPatcher(); |
||
| 36 | $base = array( 4, 2 ); |
||
| 37 | $diff = new Diff(); |
||
| 38 | $expected = array( 4, 2 ); |
||
| 39 | |||
| 40 | $argLists[] = array( $patcher, $base, $diff, $expected ); |
||
| 41 | |||
| 42 | $patcher = new ListPatcher(); |
||
| 43 | $base = array(); |
||
| 44 | $diff = new Diff( array( |
||
| 45 | new DiffOpAdd( 9001 ) |
||
| 46 | ) ); |
||
| 47 | $expected = array( 9001 ); |
||
| 48 | |||
| 49 | $argLists[] = array( $patcher, $base, $diff, $expected ); |
||
| 50 | |||
| 51 | $patcher = new ListPatcher(); |
||
| 52 | $base = array( 4, 2 ); |
||
| 53 | $diff = new Diff( array( |
||
| 54 | new DiffOpAdd( 9001 ) |
||
| 55 | ) ); |
||
| 56 | $expected = array( 4, 2, 9001 ); |
||
| 57 | |||
| 58 | $argLists[] = array( $patcher, $base, $diff, $expected ); |
||
| 59 | |||
| 60 | $patcher = new ListPatcher(); |
||
| 61 | $base = array( 4, 2 ); |
||
| 62 | $diff = new Diff( array( |
||
| 63 | new DiffOpAdd( 9001 ), |
||
| 64 | new DiffOpAdd( 9002 ), |
||
| 65 | new DiffOpAdd( 2 ) |
||
| 66 | ) ); |
||
| 67 | $expected = array( 4, 2, 9001, 9002, 2 ); |
||
| 68 | |||
| 69 | $argLists[] = array( $patcher, $base, $diff, $expected ); |
||
| 70 | |||
| 71 | $patcher = new ListPatcher(); |
||
| 72 | $base = array( 0, 1, 2, 3, 4 ); |
||
| 73 | $diff = new Diff( array( |
||
| 74 | new DiffOpRemove( 2 ), |
||
| 75 | new DiffOpRemove( 3 ), |
||
| 76 | ) ); |
||
| 77 | $expected = array( 0, 1, 4 ); |
||
| 78 | |||
| 79 | $argLists[] = array( $patcher, $base, $diff, $expected ); |
||
| 80 | |||
| 81 | $patcher = new ListPatcher(); |
||
| 82 | $base = array( 0, 1, 2, 2, 2, 3, 4 ); |
||
| 83 | $diff = new Diff( array( |
||
| 84 | new DiffOpRemove( 2 ), |
||
| 85 | new DiffOpRemove( 3 ), |
||
| 86 | new DiffOpAdd( 6 ), |
||
| 87 | new DiffOpRemove( 2 ), |
||
| 88 | ) ); |
||
| 89 | $expected = array( 0, 1, 2, 4, 6 ); |
||
| 90 | |||
| 91 | $argLists[] = array( $patcher, $base, $diff, $expected ); |
||
| 92 | |||
| 93 | $patcher = new ListPatcher(); |
||
| 94 | $base = array( |
||
| 95 | $this->newObject( 'foo' ), |
||
| 96 | $this->newObject( 'bar' ), |
||
| 97 | ); |
||
| 98 | $diff = new Diff( array( |
||
| 99 | new DiffOpRemove( $this->newObject( 'foo' ) ), |
||
| 100 | new DiffOpAdd( $this->newObject( 'baz' ) ), |
||
| 101 | ) ); |
||
| 102 | $expected = array( $this->newObject( 'bar' ), $this->newObject( 'baz' ) ); |
||
| 103 | |||
| 104 | $argLists[] = array( $patcher, $base, $diff, $expected ); |
||
| 105 | |||
| 106 | return $argLists; |
||
| 107 | } |
||
| 108 | |||
| 259 |