| Conditions | 1 |
| Paths | 1 |
| Total Lines | 84 |
| Code Lines | 21 |
| 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 |
||
| 63 | public function arrayProvider(): array |
||
| 64 | { |
||
| 65 | return [ |
||
| 66 | // test equal lists (result is unique) |
||
| 67 | [ |
||
| 68 | [1, 2], |
||
| 69 | [1, 2], |
||
| 70 | [1, 2], |
||
| 71 | ], |
||
| 72 | // test associated lists |
||
| 73 | [ |
||
| 74 | [1, 2], |
||
| 75 | [1 => 3], |
||
| 76 | [1, 3], |
||
| 77 | ], |
||
| 78 | // test combined |
||
| 79 | [ |
||
| 80 | ['key' => [1, 2]], |
||
| 81 | ['key' => [2, 3, 4]], |
||
| 82 | ['key' => [1, 2, 3, 4]], // result is unique |
||
| 83 | ], |
||
| 84 | // test mixed |
||
| 85 | [ |
||
| 86 | ['a' => 'z', 'bar' => 'baz'], |
||
| 87 | [1, 2], |
||
| 88 | ['a' => 'z', 'bar' => 'baz', 1, 2], |
||
| 89 | ], |
||
| 90 | // test mixed 2 |
||
| 91 | [ |
||
| 92 | [1 => 2, 3 => 4], |
||
| 93 | [1, 2], |
||
| 94 | [1 => 2, 3 => 4, 1], |
||
| 95 | ], |
||
| 96 | // test lists 2 |
||
| 97 | [ |
||
| 98 | [1, 3, 5], |
||
| 99 | [1, 2, 4, 6], |
||
| 100 | [1, 3, 5, 2, 4, 6], |
||
| 101 | ], |
||
| 102 | // test deep structured |
||
| 103 | [ |
||
| 104 | [ |
||
| 105 | 1 => [ |
||
| 106 | 2 => [ |
||
| 107 | 3 => 4 |
||
| 108 | ], |
||
| 109 | ], |
||
| 110 | ], |
||
| 111 | [ |
||
| 112 | 1 => [ |
||
| 113 | 2 => [ |
||
| 114 | 3 |
||
| 115 | ], |
||
| 116 | ], |
||
| 117 | 5 |
||
| 118 | ], |
||
| 119 | [ |
||
| 120 | 1 => [ |
||
| 121 | 2 => [ |
||
| 122 | 3 => 4, |
||
| 123 | 3 |
||
| 124 | ], |
||
| 125 | ], |
||
| 126 | 5 |
||
| 127 | ], |
||
| 128 | ], |
||
| 129 | // test 2 lists |
||
| 130 | [ |
||
| 131 | [ |
||
| 132 | [ |
||
| 133 | 'name' => 'A', |
||
| 134 | ], |
||
| 135 | ], |
||
| 136 | [ |
||
| 137 | [ |
||
| 138 | 'name' => 'B', |
||
| 139 | ], |
||
| 140 | ], |
||
| 141 | [ |
||
| 142 | [ |
||
| 143 | 'name' => 'A', |
||
| 144 | ], |
||
| 145 | [ |
||
| 146 | 'name' => 'B', |
||
| 147 | ], |
||
| 153 |