| Conditions | 6 |
| Paths | 1 |
| Total Lines | 68 |
| Code Lines | 41 |
| 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 |
||
| 127 | public function fileListQueryDataProvider() |
||
| 128 | { |
||
| 129 | return [ |
||
| 130 | 'sql that inserts more then 5 records' => [ |
||
| 131 | '$expectedItems' => [ |
||
| 132 | 'sql/EB-001-data.sql', |
||
| 133 | 'sql/EB-004-much-more-data.sql', |
||
| 134 | ], |
||
| 135 | '$itemsProvider' => function () { |
||
| 136 | return FullChangeSet::get()->filter( |
||
| 137 | function (FileInfo $file) { |
||
| 138 | $checkStatements = function ($checkStatements, $statements) { |
||
| 139 | foreach ($statements as $statement) { |
||
| 140 | if ($statement instanceof TransactionStatement) { |
||
| 141 | if ($checkStatements($checkStatements, $statement->statements)) { |
||
| 142 | return true; |
||
| 143 | } |
||
| 144 | } elseif ($statement instanceof InsertStatement) { |
||
| 145 | if (count($statement->values) > 5) { |
||
| 146 | return true; |
||
| 147 | } |
||
| 148 | } |
||
| 149 | } |
||
| 150 | |||
| 151 | return false; |
||
| 152 | }; |
||
| 153 | |||
| 154 | return $checkStatements($checkStatements, $file->getSqlParser()->statements); |
||
| 155 | } |
||
| 156 | )->toArray(); |
||
| 157 | }, |
||
| 158 | ], |
||
| 159 | |||
| 160 | 'sql with ddl' => [ |
||
| 161 | '$expectedItems' => [ |
||
| 162 | 'sql/EB-000-schema.sql', |
||
| 163 | 'sql/EB-002-keys-and-fix.sql', |
||
| 164 | ], |
||
| 165 | '$itemsProvider' => function () { |
||
| 166 | return FullChangeSet::get()->sqlWithDDL()->toArray(); |
||
| 167 | }, |
||
| 168 | ], |
||
| 169 | 'sql with ddl and dml' => [ |
||
| 170 | '$expectedItems' => [ |
||
| 171 | 'sql/EB-002-keys-and-fix.sql', |
||
| 172 | ], |
||
| 173 | '$itemsProvider' => function () { |
||
| 174 | return FullChangeSet::get()->sqlWithDDL()->sqlWithDML()->toArray(); |
||
| 175 | }, |
||
| 176 | ], |
||
| 177 | 'sql without ddl and dml' => [ |
||
| 178 | '$expectedItems' => [ |
||
| 179 | 'sql/EB-002-keys-and-fix.sql', |
||
| 180 | ], |
||
| 181 | '$itemsProvider' => function () { |
||
| 182 | return FullChangeSet::get()->sqlWithoutDDL()->sqlWithoutDML()->toArray(); |
||
| 183 | }, |
||
| 184 | ], |
||
| 185 | 'sql with tcl' => [ |
||
| 186 | '$expectedItems' => [ |
||
| 187 | 'sql/EB-004-much-more-data.sql' |
||
| 188 | ], |
||
| 189 | '$itemsProvider' => function () { |
||
| 190 | return FullChangeSet::get()->sqlWithTCL()->toArray(); |
||
| 191 | }, |
||
| 192 | ], |
||
| 193 | ]; |
||
| 194 | } |
||
| 195 | } |
||
| 196 |