Conditions | 1 |
Paths | 1 |
Total Lines | 243 |
Code Lines | 124 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 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 |
||
33 | public static function getFlagsProvider(): array |
||
34 | { |
||
35 | return [ |
||
36 | [ |
||
37 | 'ALTER TABLE DROP col', |
||
38 | [ |
||
39 | 'reload' => true, |
||
40 | 'queryType' => StatementType::Alter, |
||
41 | ], |
||
42 | ], |
||
43 | [ |
||
44 | 'CALL test()', |
||
45 | [ |
||
46 | 'isProcedure' => true, |
||
47 | 'queryType' => StatementType::Call, |
||
48 | ], |
||
49 | ], |
||
50 | [ |
||
51 | 'CREATE TABLE tbl (id INT)', |
||
52 | [ |
||
53 | 'reload' => true, |
||
54 | 'queryType' => StatementType::Create, |
||
55 | ], |
||
56 | ], |
||
57 | [ |
||
58 | 'CHECK TABLE tbl', |
||
59 | [ |
||
60 | 'isMaint' => true, |
||
61 | 'queryType' => StatementType::Check, |
||
62 | ], |
||
63 | ], |
||
64 | [ |
||
65 | 'DELETE FROM tbl', |
||
66 | [ |
||
67 | 'isAffected' => true, |
||
68 | 'isDelete' => true, |
||
69 | 'queryType' => StatementType::Delete, |
||
70 | ], |
||
71 | ], |
||
72 | [ |
||
73 | 'DROP VIEW v', |
||
74 | [ |
||
75 | 'reload' => true, |
||
76 | 'queryType' => StatementType::Drop, |
||
77 | ], |
||
78 | ], |
||
79 | [ |
||
80 | 'DROP DATABASE db', |
||
81 | [ |
||
82 | 'dropDatabase' => true, |
||
83 | 'reload' => true, |
||
84 | 'queryType' => StatementType::Drop, |
||
85 | ], |
||
86 | ], |
||
87 | [ |
||
88 | 'EXPLAIN tbl', |
||
89 | [ |
||
90 | 'isExplain' => true, |
||
91 | 'queryType' => StatementType::Explain, |
||
92 | ], |
||
93 | ], |
||
94 | [ |
||
95 | 'LOAD DATA INFILE \'/tmp/test.txt\' INTO TABLE test', |
||
96 | [ |
||
97 | 'isAffected' => true, |
||
98 | 'isInsert' => true, |
||
99 | 'queryType' => StatementType::Load, |
||
100 | ], |
||
101 | ], |
||
102 | [ |
||
103 | 'INSERT INTO tbl VALUES (1)', |
||
104 | [ |
||
105 | 'isAffected' => true, |
||
106 | 'isInsert' => true, |
||
107 | 'queryType' => StatementType::Insert, |
||
108 | ], |
||
109 | ], |
||
110 | [ |
||
111 | 'REPLACE INTO tbl VALUES (2)', |
||
112 | [ |
||
113 | 'isAffected' => true, |
||
114 | 'isReplace' => true, |
||
115 | 'isInsert' => true, |
||
116 | 'queryType' => StatementType::Replace, |
||
117 | ], |
||
118 | ], |
||
119 | [ |
||
120 | 'SELECT 1', |
||
121 | [ |
||
122 | 'isSelect' => true, |
||
123 | 'queryType' => StatementType::Select, |
||
124 | ], |
||
125 | ], |
||
126 | [ |
||
127 | 'SELECT * FROM tbl', |
||
128 | [ |
||
129 | 'isSelect' => true, |
||
130 | 'selectFrom' => true, |
||
131 | 'queryType' => StatementType::Select, |
||
132 | ], |
||
133 | ], |
||
134 | [ |
||
135 | 'SELECT DISTINCT * FROM tbl LIMIT 0, 10 ORDER BY id', |
||
136 | [ |
||
137 | 'distinct' => true, |
||
138 | 'isSelect' => true, |
||
139 | 'selectFrom' => true, |
||
140 | 'limit' => true, |
||
141 | 'order' => true, |
||
142 | 'queryType' => StatementType::Select, |
||
143 | ], |
||
144 | ], |
||
145 | [ |
||
146 | 'SELECT * FROM actor GROUP BY actor_id', |
||
147 | [ |
||
148 | 'isGroup' => true, |
||
149 | 'isSelect' => true, |
||
150 | 'selectFrom' => true, |
||
151 | 'group' => true, |
||
152 | 'queryType' => StatementType::Select, |
||
153 | ], |
||
154 | ], |
||
155 | [ |
||
156 | 'SELECT col1, col2 FROM table1 PROCEDURE ANALYSE(10, 2000);', |
||
157 | [ |
||
158 | 'isAnalyse' => true, |
||
159 | 'isSelect' => true, |
||
160 | 'selectFrom' => true, |
||
161 | 'queryType' => StatementType::Select, |
||
162 | ], |
||
163 | ], |
||
164 | [ |
||
165 | 'SELECT * FROM tbl INTO OUTFILE "/tmp/export.txt"', |
||
166 | [ |
||
167 | 'isExport' => true, |
||
168 | 'isSelect' => true, |
||
169 | 'selectFrom' => true, |
||
170 | 'queryType' => StatementType::Select, |
||
171 | ], |
||
172 | ], |
||
173 | [ |
||
174 | 'SELECT COUNT(id), SUM(id) FROM tbl', |
||
175 | [ |
||
176 | 'isCount' => true, |
||
177 | 'isFunc' => true, |
||
178 | 'isSelect' => true, |
||
179 | 'selectFrom' => true, |
||
180 | 'queryType' => StatementType::Select, |
||
181 | ], |
||
182 | ], |
||
183 | [ |
||
184 | 'SELECT (SELECT "foo")', |
||
185 | [ |
||
186 | 'isSelect' => true, |
||
187 | 'isSubQuery' => true, |
||
188 | 'queryType' => StatementType::Select, |
||
189 | ], |
||
190 | ], |
||
191 | [ |
||
192 | 'SELECT * FROM customer HAVING store_id = 2;', |
||
193 | [ |
||
194 | 'isSelect' => true, |
||
195 | 'selectFrom' => true, |
||
196 | 'isGroup' => true, |
||
197 | 'having' => true, |
||
198 | 'queryType' => StatementType::Select, |
||
199 | ], |
||
200 | ], |
||
201 | [ |
||
202 | 'SELECT * FROM table1 INNER JOIN table2 ON table1.id=table2.id;', |
||
203 | [ |
||
204 | 'isSelect' => true, |
||
205 | 'selectFrom' => true, |
||
206 | 'join' => true, |
||
207 | 'queryType' => StatementType::Select, |
||
208 | ], |
||
209 | ], |
||
210 | [ |
||
211 | 'SHOW CREATE TABLE tbl', |
||
212 | [ |
||
213 | 'isShow' => true, |
||
214 | 'queryType' => StatementType::Show, |
||
215 | ], |
||
216 | ], |
||
217 | [ |
||
218 | 'UPDATE tbl SET id = 1', |
||
219 | [ |
||
220 | 'isAffected' => true, |
||
221 | 'queryType' => StatementType::Update, |
||
222 | ], |
||
223 | ], |
||
224 | [ |
||
225 | 'ANALYZE TABLE tbl', |
||
226 | [ |
||
227 | 'isMaint' => true, |
||
228 | 'queryType' => StatementType::Analyze, |
||
229 | ], |
||
230 | ], |
||
231 | [ |
||
232 | 'CHECKSUM TABLE tbl', |
||
233 | [ |
||
234 | 'isMaint' => true, |
||
235 | 'queryType' => StatementType::Checksum, |
||
236 | ], |
||
237 | ], |
||
238 | [ |
||
239 | 'OPTIMIZE TABLE tbl', |
||
240 | [ |
||
241 | 'isMaint' => true, |
||
242 | 'queryType' => StatementType::Optimize, |
||
243 | ], |
||
244 | ], |
||
245 | [ |
||
246 | 'REPAIR TABLE tbl', |
||
247 | [ |
||
248 | 'isMaint' => true, |
||
249 | 'queryType' => StatementType::Repair, |
||
250 | ], |
||
251 | ], |
||
252 | [ |
||
253 | '(SELECT a FROM t1 WHERE a=10 AND B=1 ORDER BY a LIMIT 10) ' . |
||
254 | 'UNION ' . |
||
255 | '(SELECT a FROM t2 WHERE a=11 AND B=2 ORDER BY a LIMIT 10);', |
||
256 | [ |
||
257 | 'isSelect' => true, |
||
258 | 'selectFrom' => true, |
||
259 | 'limit' => true, |
||
260 | 'order' => true, |
||
261 | 'union' => true, |
||
262 | 'queryType' => StatementType::Select, |
||
263 | ], |
||
264 | ], |
||
265 | [ |
||
266 | 'SELECT * FROM orders AS ord WHERE 1', |
||
267 | [ |
||
268 | 'queryType' => StatementType::Select, |
||
269 | 'isSelect' => true, |
||
270 | 'selectFrom' => true, |
||
271 | ], |
||
272 | ], |
||
273 | [ |
||
274 | 'SET NAMES \'latin\'', |
||
275 | ['queryType' => StatementType::Set], |
||
276 | ], |
||
692 |
This property has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.