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