| Conditions | 1 |
| Paths | 1 |
| Total Lines | 243 |
| Code Lines | 124 |
| 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 |
||
| 29 | public function getFlagsProvider() |
||
| 30 | { |
||
| 31 | return [ |
||
| 32 | [ |
||
| 33 | 'ALTER TABLE DROP col', |
||
| 34 | [ |
||
| 35 | 'reload' => true, |
||
| 36 | 'querytype' => 'ALTER', |
||
| 37 | ], |
||
| 38 | ], |
||
| 39 | [ |
||
| 40 | 'CALL test()', |
||
| 41 | [ |
||
| 42 | 'is_procedure' => true, |
||
| 43 | 'querytype' => 'CALL', |
||
| 44 | ], |
||
| 45 | ], |
||
| 46 | [ |
||
| 47 | 'CREATE TABLE tbl (id INT)', |
||
| 48 | [ |
||
| 49 | 'reload' => true, |
||
| 50 | 'querytype' => 'CREATE', |
||
| 51 | ], |
||
| 52 | ], |
||
| 53 | [ |
||
| 54 | 'CHECK TABLE tbl', |
||
| 55 | [ |
||
| 56 | 'is_maint' => true, |
||
| 57 | 'querytype' => 'CHECK', |
||
| 58 | ], |
||
| 59 | ], |
||
| 60 | [ |
||
| 61 | 'DELETE FROM tbl', |
||
| 62 | [ |
||
| 63 | 'is_affected' => true, |
||
| 64 | 'is_delete' => true, |
||
| 65 | 'querytype' => 'DELETE', |
||
| 66 | ], |
||
| 67 | ], |
||
| 68 | [ |
||
| 69 | 'DROP VIEW v', |
||
| 70 | [ |
||
| 71 | 'reload' => true, |
||
| 72 | 'querytype' => 'DROP', |
||
| 73 | ], |
||
| 74 | ], |
||
| 75 | [ |
||
| 76 | 'DROP DATABASE db', |
||
| 77 | [ |
||
| 78 | 'drop_database' => true, |
||
| 79 | 'reload' => true, |
||
| 80 | 'querytype' => 'DROP', |
||
| 81 | ], |
||
| 82 | ], |
||
| 83 | [ |
||
| 84 | 'EXPLAIN tbl', |
||
| 85 | [ |
||
| 86 | 'is_explain' => true, |
||
| 87 | 'querytype' => 'EXPLAIN', |
||
| 88 | ], |
||
| 89 | ], |
||
| 90 | [ |
||
| 91 | 'LOAD DATA INFILE \'/tmp/test.txt\' INTO TABLE test', |
||
| 92 | [ |
||
| 93 | 'is_affected' => true, |
||
| 94 | 'is_insert' => true, |
||
| 95 | 'querytype' => 'LOAD', |
||
| 96 | ], |
||
| 97 | ], |
||
| 98 | [ |
||
| 99 | 'INSERT INTO tbl VALUES (1)', |
||
| 100 | [ |
||
| 101 | 'is_affected' => true, |
||
| 102 | 'is_insert' => true, |
||
| 103 | 'querytype' => 'INSERT', |
||
| 104 | ], |
||
| 105 | ], |
||
| 106 | [ |
||
| 107 | 'REPLACE INTO tbl VALUES (2)', |
||
| 108 | [ |
||
| 109 | 'is_affected' => true, |
||
| 110 | 'is_replace' => true, |
||
| 111 | 'is_insert' => true, |
||
| 112 | 'querytype' => 'REPLACE', |
||
| 113 | ], |
||
| 114 | ], |
||
| 115 | [ |
||
| 116 | 'SELECT 1', |
||
| 117 | [ |
||
| 118 | 'is_select' => true, |
||
| 119 | 'querytype' => 'SELECT', |
||
| 120 | ], |
||
| 121 | ], |
||
| 122 | [ |
||
| 123 | 'SELECT * FROM tbl', |
||
| 124 | [ |
||
| 125 | 'is_select' => true, |
||
| 126 | 'select_from' => true, |
||
| 127 | 'querytype' => 'SELECT', |
||
| 128 | ], |
||
| 129 | ], |
||
| 130 | [ |
||
| 131 | 'SELECT DISTINCT * FROM tbl LIMIT 0, 10 ORDER BY id', |
||
| 132 | [ |
||
| 133 | 'distinct' => true, |
||
| 134 | 'is_select' => true, |
||
| 135 | 'select_from' => true, |
||
| 136 | 'limit' => true, |
||
| 137 | 'order' => true, |
||
| 138 | 'querytype' => 'SELECT', |
||
| 139 | ], |
||
| 140 | ], |
||
| 141 | [ |
||
| 142 | 'SELECT * FROM actor GROUP BY actor_id', |
||
| 143 | [ |
||
| 144 | 'is_group' => true, |
||
| 145 | 'is_select' => true, |
||
| 146 | 'select_from' => true, |
||
| 147 | 'group' => true, |
||
| 148 | 'querytype' => 'SELECT', |
||
| 149 | ], |
||
| 150 | ], |
||
| 151 | [ |
||
| 152 | 'SELECT col1, col2 FROM table1 PROCEDURE ANALYSE(10, 2000);', |
||
| 153 | [ |
||
| 154 | 'is_analyse' => true, |
||
| 155 | 'is_select' => true, |
||
| 156 | 'select_from' => true, |
||
| 157 | 'querytype' => 'SELECT', |
||
| 158 | ], |
||
| 159 | ], |
||
| 160 | [ |
||
| 161 | 'SELECT * FROM tbl INTO OUTFILE "/tmp/export.txt"', |
||
| 162 | [ |
||
| 163 | 'is_export' => true, |
||
| 164 | 'is_select' => true, |
||
| 165 | 'select_from' => true, |
||
| 166 | 'querytype' => 'SELECT', |
||
| 167 | ], |
||
| 168 | ], |
||
| 169 | [ |
||
| 170 | 'SELECT COUNT(id), SUM(id) FROM tbl', |
||
| 171 | [ |
||
| 172 | 'is_count' => true, |
||
| 173 | 'is_func' => true, |
||
| 174 | 'is_select' => true, |
||
| 175 | 'select_from' => true, |
||
| 176 | 'querytype' => 'SELECT', |
||
| 177 | ], |
||
| 178 | ], |
||
| 179 | [ |
||
| 180 | 'SELECT (SELECT "foo")', |
||
| 181 | [ |
||
| 182 | 'is_select' => true, |
||
| 183 | 'is_subquery' => true, |
||
| 184 | 'querytype' => 'SELECT', |
||
| 185 | ], |
||
| 186 | ], |
||
| 187 | [ |
||
| 188 | 'SELECT * FROM customer HAVING store_id = 2;', |
||
| 189 | [ |
||
| 190 | 'is_select' => true, |
||
| 191 | 'select_from' => true, |
||
| 192 | 'is_group' => true, |
||
| 193 | 'having' => true, |
||
| 194 | 'querytype' => 'SELECT', |
||
| 195 | ], |
||
| 196 | ], |
||
| 197 | [ |
||
| 198 | 'SELECT * FROM table1 INNER JOIN table2 ON table1.id=table2.id;', |
||
| 199 | [ |
||
| 200 | 'is_select' => true, |
||
| 201 | 'select_from' => true, |
||
| 202 | 'join' => true, |
||
| 203 | 'querytype' => 'SELECT', |
||
| 204 | ], |
||
| 205 | ], |
||
| 206 | [ |
||
| 207 | 'SHOW CREATE TABLE tbl', |
||
| 208 | [ |
||
| 209 | 'is_show' => true, |
||
| 210 | 'querytype' => 'SHOW', |
||
| 211 | ], |
||
| 212 | ], |
||
| 213 | [ |
||
| 214 | 'UPDATE tbl SET id = 1', |
||
| 215 | [ |
||
| 216 | 'is_affected' => true, |
||
| 217 | 'querytype' => 'UPDATE', |
||
| 218 | ], |
||
| 219 | ], |
||
| 220 | [ |
||
| 221 | 'ANALYZE TABLE tbl', |
||
| 222 | [ |
||
| 223 | 'is_maint' => true, |
||
| 224 | 'querytype' => 'ANALYZE', |
||
| 225 | ], |
||
| 226 | ], |
||
| 227 | [ |
||
| 228 | 'CHECKSUM TABLE tbl', |
||
| 229 | [ |
||
| 230 | 'is_maint' => true, |
||
| 231 | 'querytype' => 'CHECKSUM', |
||
| 232 | ], |
||
| 233 | ], |
||
| 234 | [ |
||
| 235 | 'OPTIMIZE TABLE tbl', |
||
| 236 | [ |
||
| 237 | 'is_maint' => true, |
||
| 238 | 'querytype' => 'OPTIMIZE', |
||
| 239 | ], |
||
| 240 | ], |
||
| 241 | [ |
||
| 242 | 'REPAIR TABLE tbl', |
||
| 243 | [ |
||
| 244 | 'is_maint' => true, |
||
| 245 | 'querytype' => 'REPAIR', |
||
| 246 | ], |
||
| 247 | ], |
||
| 248 | [ |
||
| 249 | '(SELECT a FROM t1 WHERE a=10 AND B=1 ORDER BY a LIMIT 10) ' . |
||
| 250 | 'UNION ' . |
||
| 251 | '(SELECT a FROM t2 WHERE a=11 AND B=2 ORDER BY a LIMIT 10);', |
||
| 252 | [ |
||
| 253 | 'is_select' => true, |
||
| 254 | 'select_from' => true, |
||
| 255 | 'limit' => true, |
||
| 256 | 'order' => true, |
||
| 257 | 'union' => true, |
||
| 258 | 'querytype' => 'SELECT', |
||
| 259 | ], |
||
| 260 | ], |
||
| 261 | [ |
||
| 262 | 'SELECT * FROM orders AS ord WHERE 1', |
||
| 263 | [ |
||
| 264 | 'querytype' => 'SELECT', |
||
| 265 | 'is_select' => true, |
||
| 266 | 'select_from' => true, |
||
| 267 | ], |
||
| 268 | ], |
||
| 269 | [ |
||
| 270 | 'SET NAMES \'latin\'', |
||
| 271 | ['querytype' => 'SET'], |
||
| 272 | ], |
||
| 713 |