Conditions | 1 |
Paths | 1 |
Total Lines | 318 |
Code Lines | 251 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 1 | Features | 1 |
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 |
||
94 | public function get_item_schema() { |
||
95 | $schema = array( |
||
96 | '$schema' => 'http://json-schema.org/draft-04/schema#', |
||
97 | 'title' => 'system_status', |
||
98 | 'type' => 'object', |
||
99 | 'properties' => array( |
||
100 | 'environment' => array( |
||
101 | 'description' => __( 'Environment', 'woocommerce' ), |
||
102 | 'type' => 'array', |
||
103 | 'context' => array( 'view', 'edit' ), |
||
104 | 'properties' => array( |
||
105 | 'home_url' => array( |
||
106 | 'description' => __( 'Home URL', 'woocommerce' ), |
||
107 | 'type' => 'string', |
||
108 | 'format' => 'uri', |
||
109 | 'context' => array( 'view', 'edit' ), |
||
110 | ), |
||
111 | 'site_url' => array( |
||
112 | 'description' => __( 'Site URL', 'woocommerce' ), |
||
113 | 'type' => 'string', |
||
114 | 'format' => 'uri', |
||
115 | 'context' => array( 'view', 'edit' ), |
||
116 | ), |
||
117 | 'wc_version' => array( |
||
118 | 'description' => __( 'WooCommerce Version', 'woocommerce' ), |
||
119 | 'type' => 'string', |
||
120 | 'context' => array( 'view', 'edit' ), |
||
121 | ), |
||
122 | 'log_directory' => array( |
||
123 | 'description' => __( 'Log Directory', 'woocommerce' ), |
||
124 | 'type' => 'string', |
||
125 | 'context' => array( 'view', 'edit' ), |
||
126 | ), |
||
127 | 'log_directory_writable' => array( |
||
128 | 'description' => __( 'Is Log Directory Writable?', 'woocommerce' ), |
||
129 | 'type' => 'boolean', |
||
130 | 'context' => array( 'view', 'edit' ), |
||
131 | ), |
||
132 | 'wp_version' => array( |
||
133 | 'description' => __( 'WordPress Version', 'woocommerce' ), |
||
134 | 'type' => 'string', |
||
135 | 'context' => array( 'view', 'edit' ), |
||
136 | ), |
||
137 | 'wp_multisite' => array( |
||
138 | 'description' => __( 'Is WordPress Multisite?', 'woocommerce' ), |
||
139 | 'type' => 'boolean', |
||
140 | 'context' => array( 'view', 'edit' ), |
||
141 | ), |
||
142 | 'wp_memory_limit' => array( |
||
143 | 'description' => __( 'WordPress Memory Limit', 'woocommerce' ), |
||
144 | 'type' => 'integer', |
||
145 | 'context' => array( 'view', 'edit' ), |
||
146 | ), |
||
147 | 'wp_debug_mode' => array( |
||
148 | 'description' => __( 'Is WordPress Debug Mode Active?', 'woocommerce' ), |
||
149 | 'type' => 'boolean', |
||
150 | 'context' => array( 'view', 'edit' ), |
||
151 | ), |
||
152 | 'wp_cron' => array( |
||
153 | 'description' => __( 'Are WordPress Cron Jobs Enabled?', 'woocommerce' ), |
||
154 | 'type' => 'boolean', |
||
155 | 'context' => array( 'view', 'edit' ), |
||
156 | ), |
||
157 | 'language' => array( |
||
158 | 'description' => __( 'WordPress Language', 'woocommerce' ), |
||
159 | 'type' => 'string', |
||
160 | 'context' => array( 'view', 'edit' ), |
||
161 | ), |
||
162 | 'server_info' => array( |
||
163 | 'description' => __( 'Server Info', 'woocommerce' ), |
||
164 | 'type' => 'string', |
||
165 | 'context' => array( 'view', 'edit' ), |
||
166 | ), |
||
167 | 'php_version' => array( |
||
168 | 'description' => __( 'PHP Version', 'woocommerce' ), |
||
169 | 'type' => 'string', |
||
170 | 'context' => array( 'view', 'edit' ), |
||
171 | ), |
||
172 | 'php_post_max_size' => array( |
||
173 | 'description' => __( 'PHP Post Max Size', 'woocommerce' ), |
||
174 | 'type' => 'integer', |
||
175 | 'context' => array( 'view', 'edit' ), |
||
176 | ), |
||
177 | 'php_max_execution_time' => array( |
||
178 | 'description' => __( 'PHP Max Execution Time', 'woocommerce' ), |
||
179 | 'type' => 'integer', |
||
180 | 'context' => array( 'view', 'edit' ), |
||
181 | ), |
||
182 | 'php_max_input_vars' => array( |
||
183 | 'description' => __( 'PHP Max Input Vars', 'woocommerce' ), |
||
184 | 'type' => 'integer', |
||
185 | 'context' => array( 'view', 'edit' ), |
||
186 | ), |
||
187 | 'curl_version' => array( |
||
188 | 'description' => __( 'cURL Version', 'woocommerce' ), |
||
189 | 'type' => 'string', |
||
190 | 'context' => array( 'view', 'edit' ), |
||
191 | ), |
||
192 | 'suhosin_installed' => array( |
||
193 | 'description' => __( 'Is SUHOSIN Installed?', 'woocommerce' ), |
||
194 | 'type' => 'boolean', |
||
195 | 'context' => array( 'view', 'edit' ), |
||
196 | ), |
||
197 | 'max_upload_size' => array( |
||
198 | 'description' => __( 'Max Upload Size', 'woocommerce' ), |
||
199 | 'type' => 'integer', |
||
200 | 'context' => array( 'view', 'edit' ), |
||
201 | ), |
||
202 | 'mysql_version' => array( |
||
203 | 'description' => __( 'MySQL Version', 'woocommerce' ), |
||
204 | 'type' => 'string', |
||
205 | 'context' => array( 'view', 'edit' ), |
||
206 | ), |
||
207 | 'default_timezone' => array( |
||
208 | 'description' => __( 'Default Timezone', 'woocommerce' ), |
||
209 | 'type' => 'string', |
||
210 | 'context' => array( 'view', 'edit' ), |
||
211 | ), |
||
212 | 'fsockopen_or_curl_enabled' => array( |
||
213 | 'description' => __( 'Is fsockopen/cURL Enabled?', 'woocommerce' ), |
||
214 | 'type' => 'boolean', |
||
215 | 'context' => array( 'view', 'edit' ), |
||
216 | ), |
||
217 | 'soapclient_enabled' => array( |
||
218 | 'description' => __( 'Is SoapClient Class Enabled?', 'woocommerce' ), |
||
219 | 'type' => 'boolean', |
||
220 | 'context' => array( 'view', 'edit' ), |
||
221 | ), |
||
222 | 'domdocument_enabled' => array( |
||
223 | 'description' => __( 'Is DomDocument Class Enabled?', 'woocommerce' ), |
||
224 | 'type' => 'boolean', |
||
225 | 'context' => array( 'view', 'edit' ), |
||
226 | ), |
||
227 | 'gzip_enabled' => array( |
||
228 | 'description' => __( 'Is GZip Enabled?', 'woocommerce' ), |
||
229 | 'type' => 'boolean', |
||
230 | 'context' => array( 'view', 'edit' ), |
||
231 | ), |
||
232 | 'mbstring_enabled' => array( |
||
233 | 'description' => __( 'Is mbstring Enabled?', 'woocommerce' ), |
||
234 | 'type' => 'boolean', |
||
235 | 'context' => array( 'view', 'edit' ), |
||
236 | ), |
||
237 | 'remote_post_successful' => array( |
||
238 | 'description' => __( 'Remote POST Successful?', 'woocommerce' ), |
||
239 | 'type' => 'boolean', |
||
240 | 'context' => array( 'view', 'edit' ), |
||
241 | ), |
||
242 | 'remote_post_response' => array( |
||
243 | 'description' => __( 'Remote POST Response', 'woocommerce' ), |
||
244 | 'type' => 'string', |
||
245 | 'context' => array( 'view', 'edit' ), |
||
246 | ), |
||
247 | 'remote_get_successful' => array( |
||
248 | 'description' => __( 'Remote GET Successful?', 'woocommerce' ), |
||
249 | 'type' => 'boolean', |
||
250 | 'context' => array( 'view', 'edit' ), |
||
251 | ), |
||
252 | 'remote_get_response' => array( |
||
253 | 'description' => __( 'Remote GET Response', 'woocommerce' ), |
||
254 | 'type' => 'string', |
||
255 | 'context' => array( 'view', 'edit' ), |
||
256 | ), |
||
257 | ), |
||
258 | ), |
||
259 | 'database' => array( |
||
260 | 'description' => __( 'Database', 'woocommerce' ), |
||
261 | 'type' => 'array', |
||
262 | 'context' => array( 'view', 'edit' ), |
||
263 | 'properties' => array( |
||
264 | 'wc_database_version' => array( |
||
265 | 'description' => __( 'WC Database Version', 'woocommerce' ), |
||
266 | 'type' => 'string', |
||
267 | 'context' => array( 'view', 'edit' ), |
||
268 | ), |
||
269 | 'database_prefix' => array( |
||
270 | 'description' => __( 'Database Prefix', 'woocommerce' ), |
||
271 | 'type' => 'string', |
||
272 | 'context' => array( 'view', 'edit' ), |
||
273 | ), |
||
274 | 'maxmind_geoip_database' => array( |
||
275 | 'description' => __( 'MaxMind GeoIP Database', 'woocommerce' ), |
||
276 | 'type' => 'string', |
||
277 | 'context' => array( 'view', 'edit' ), |
||
278 | ), |
||
279 | 'database_tables' => array( |
||
280 | 'description' => __( 'Database Tables', 'woocommerce' ), |
||
281 | 'type' => 'array', |
||
282 | 'context' => array( 'view', 'edit' ), |
||
283 | ), |
||
284 | ) |
||
285 | ), |
||
286 | 'active_plugins' => array( |
||
287 | 'description' => __( 'Active Plugins', 'woocommerce' ), |
||
288 | 'type' => 'array', |
||
289 | 'context' => array( 'view', 'edit' ), |
||
290 | ), |
||
291 | 'theme' => array( |
||
292 | 'description' => __( 'Theme', 'woocommerce' ), |
||
293 | 'type' => 'array', |
||
294 | 'context' => array( 'view', 'edit' ), |
||
295 | 'properties' => array( |
||
296 | 'name' => array( |
||
297 | 'description' => __( 'Theme Name', 'woocommerce' ), |
||
298 | 'type' => 'string', |
||
299 | 'context' => array( 'view', 'edit' ), |
||
300 | ), |
||
301 | 'version' => array( |
||
302 | 'description' => __( 'Theme Version', 'woocommerce' ), |
||
303 | 'type' => 'string', |
||
304 | 'context' => array( 'view', 'edit' ), |
||
305 | ), |
||
306 | 'author_url' => array( |
||
307 | 'description' => __( 'Theme Author URL', 'woocommerce' ), |
||
308 | 'type' => 'string', |
||
309 | 'format' => 'uri', |
||
310 | 'context' => array( 'view', 'edit' ), |
||
311 | ), |
||
312 | 'is_child_theme' => array( |
||
313 | 'description' => __( 'Is this theme a child theme?', 'woocommerce' ), |
||
314 | 'type' => 'boolean', |
||
315 | 'context' => array( 'view', 'edit' ), |
||
316 | ), |
||
317 | 'has_woocommerce_support' => array( |
||
318 | 'description' => __( 'Does the theme declare WooCommerce support?', 'woocommerce' ), |
||
319 | 'type' => 'boolean', |
||
320 | 'context' => array( 'view', 'edit' ), |
||
321 | ), |
||
322 | 'overrides' => array( |
||
323 | 'description' => __( 'Template Overrides', 'woocommerce' ), |
||
324 | 'type' => 'array', |
||
325 | 'context' => array( 'view', 'edit' ), |
||
326 | ), |
||
327 | 'parent_name' => array( |
||
328 | 'description' => __( 'Parent Theme Name', 'woocommerce' ), |
||
329 | 'type' => 'string', |
||
330 | 'context' => array( 'view', 'edit' ), |
||
331 | ), |
||
332 | 'parent_version' => array( |
||
333 | 'description' => __( 'Parent Theme Version', 'woocommerce' ), |
||
334 | 'type' => 'string', |
||
335 | 'context' => array( 'view', 'edit' ), |
||
336 | ), |
||
337 | 'parent_author_url' => array( |
||
338 | 'description' => __( 'Parent Theme Author URL', 'woocommerce' ), |
||
339 | 'type' => 'string', |
||
340 | 'format' => 'uri', |
||
341 | 'context' => array( 'view', 'edit' ), |
||
342 | ), |
||
343 | ) |
||
344 | ), |
||
345 | 'settings' => array( |
||
346 | 'description' => __( 'Settings', 'woocommerce' ), |
||
347 | 'type' => 'array', |
||
348 | 'context' => array( 'view', 'edit' ), |
||
349 | 'properties' => array( |
||
350 | 'api_enabled' => array( |
||
351 | 'description' => __( 'REST API Enabled?', 'woocommerce' ), |
||
352 | 'type' => 'boolean', |
||
353 | 'context' => array( 'view', 'edit' ), |
||
354 | ), |
||
355 | 'force_ssl' => array( |
||
356 | 'description' => __( 'SSL Forced?', 'woocommerce' ), |
||
357 | 'type' => 'boolean', |
||
358 | 'context' => array( 'view', 'edit' ), |
||
359 | ), |
||
360 | 'currency' => array( |
||
361 | 'description' => __( 'Currency', 'woocommerce' ), |
||
362 | 'type' => 'string', |
||
363 | 'context' => array( 'view', 'edit' ), |
||
364 | ), |
||
365 | 'currency_symbol' => array( |
||
366 | 'description' => __( 'Currency Symbol', 'woocommerce' ), |
||
367 | 'type' => 'string', |
||
368 | 'context' => array( 'view', 'edit' ), |
||
369 | ), |
||
370 | 'currency_position' => array( |
||
371 | 'description' => __( 'Currency Position', 'woocommerce' ), |
||
372 | 'type' => 'string', |
||
373 | 'context' => array( 'view', 'edit' ), |
||
374 | ), |
||
375 | 'thousand_separator' => array( |
||
376 | 'description' => __( 'Thousand Separator', 'woocommerce' ), |
||
377 | 'type' => 'string', |
||
378 | 'context' => array( 'view', 'edit' ), |
||
379 | ), |
||
380 | 'decimal_separator' => array( |
||
381 | 'description' => __( 'Decimal Separator', 'woocommerce' ), |
||
382 | 'type' => 'string', |
||
383 | 'context' => array( 'view', 'edit' ), |
||
384 | ), |
||
385 | 'number_of_decimals' => array( |
||
386 | 'description' => __( 'Number of Decimals', 'woocommerce' ), |
||
387 | 'type' => 'integer', |
||
388 | 'context' => array( 'view', 'edit' ), |
||
389 | ), |
||
390 | 'geolocation_enabled' => array( |
||
391 | 'description' => __( 'Geolocation Enabled?', 'woocommerce' ), |
||
392 | 'type' => 'boolean', |
||
393 | 'context' => array( 'view', 'edit' ), |
||
394 | ), |
||
395 | 'taxonomies' => array( |
||
396 | 'description' => __( 'Taxonomy Terms for Product/Order Statuses', 'woocommerce' ), |
||
397 | 'type' => 'array', |
||
398 | 'context' => array( 'view', 'edit' ), |
||
399 | ), |
||
400 | ) |
||
401 | ), |
||
402 | 'pages' => array( |
||
403 | 'description' => __( 'WooCommerce Pages', 'woocommerce' ), |
||
404 | 'type' => 'array', |
||
405 | 'context' => array( 'view', 'edit' ), |
||
406 | ), |
||
407 | ) |
||
408 | ); |
||
409 | |||
410 | return $this->add_additional_fields_schema( $schema ); |
||
411 | } |
||
412 | |||
748 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.