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