| Conditions | 2 |
| Paths | 2 |
| Total Lines | 67 |
| Code Lines | 60 |
| 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 |
||
| 44 | public function runIfEnabled(): void |
||
| 45 | { |
||
| 46 | remove_action('comment_post', ['WC_Comments', 'add_comment_purchase_verification'], 10); |
||
| 47 | remove_action('wp_update_comment_count', ['WC_Comments', 'clear_transients'], 10); |
||
| 48 | remove_filter('comments_open', ['WC_Comments', 'comments_open'], 10); |
||
| 49 | if ('yes' === $this->option('integrations.woocommerce.wp_comments')) { |
||
| 50 | $this->hook(ExperimentsController::class, [ |
||
| 51 | ['filterProductCommentMeta', 'get_comment_metadata', 20, 4], |
||
| 52 | ['filterProductCommentsQuery', 'comments_pre_query', 20, 2], |
||
| 53 | ]); |
||
| 54 | } |
||
| 55 | $this->hook(IntegrationController::class, [ |
||
| 56 | ['filterDiviDynamicAssetsList', 'divi_frontend_assets_dynamic_assets_global_assets_list', 10, 2], |
||
| 57 | ]); |
||
| 58 | $this->hook(MainController::class, [ |
||
| 59 | ['enqueueInlineAdminStyles', 'admin_enqueue_scripts', 20], |
||
| 60 | ['filterInlineStyles', 'site-reviews/enqueue/public/inline-styles', 20], |
||
| 61 | ['filterMenuPendingCount', 'woocommerce_product_reviews_pending_count'], |
||
| 62 | ['filterProductCommentStatus', 'get_default_comment_status', 10, 3], |
||
| 63 | ['filterProductSettings', 'woocommerce_get_settings_products', 10, 2], |
||
| 64 | ['filterPublicInlineScript', 'site-reviews/enqueue/public/inline-script/after'], |
||
| 65 | ['filterRankmathSchemaPreview', 'site-reviews/schema/generate', 10, 2], |
||
| 66 | ['filterRatingOption', 'option_woocommerce_enable_review_rating'], |
||
| 67 | ['filterRatingOption', 'option_woocommerce_review_rating_required'], |
||
| 68 | ['filterReviewAuthorTagValue', 'site-reviews/review/value/author', 10, 2], |
||
| 69 | ['filterReviewCallbackHasVerifiedOwner', 'site-reviews/review/call/hasVerifiedOwner'], |
||
| 70 | ['filterReviewCallbackProduct', 'site-reviews/review/call/product'], |
||
| 71 | ['redirectProductReviews', 'admin_init'], |
||
| 72 | ['registerElementorWidgets', 'elementor/widgets/register', 20], |
||
| 73 | ['registerWidgets', 'widgets_init', 20], |
||
| 74 | ['removeWoocommerceReviews', 'woocommerce_register_post_type_product'], |
||
| 75 | ['renderNotice', 'admin_notices'], |
||
| 76 | ['verifyProductOwner', 'site-reviews/review/created', 20], |
||
| 77 | ]); |
||
| 78 | $this->hook(ProductController::class, [ |
||
| 79 | ['filterCommentsTemplate', 'comments_template', 50], |
||
| 80 | ['filterGetRatingHtml', 'woocommerce_product_get_rating_html', 20, 3], |
||
| 81 | ['filterGetStarRatingHtml', 'woocommerce_get_star_rating_html', 10, 3], |
||
| 82 | ['filterProductAverageRating', 'woocommerce_product_get_average_rating', 10, 2], |
||
| 83 | ['filterProductDataTabs', 'woocommerce_product_data_tabs'], |
||
| 84 | ['filterProductMetaQuery', 'woocommerce_product_query_meta_query', 20], |
||
| 85 | ['filterProductPostClauses', 'woocommerce_get_catalog_ordering_args', 20, 2], |
||
| 86 | ['filterProductRatingCounts', 'woocommerce_product_get_rating_counts', 10, 2], |
||
| 87 | ['filterProductReviewCount', 'woocommerce_product_get_review_count', 10, 2], |
||
| 88 | ['filterProductTabs', 'woocommerce_product_tabs', 50], |
||
| 89 | ['filterProductTaxQuery', 'woocommerce_product_query_tax_query', 20], |
||
| 90 | ['filterStructuredData', 'woocommerce_structured_data_product', 10, 2], |
||
| 91 | ['filterWidgetArgsTopRatedProducts', 'woocommerce_top_rated_products_widget_args'], |
||
| 92 | ['filterWoocommerceTemplate', 'wc_get_template', 20, 2], |
||
| 93 | ['modifyProductQuery', 'pre_get_posts'], |
||
| 94 | ['printInlineStyle', 'admin_head'], |
||
| 95 | ['registerMetaboxes', 'add_meta_boxes_product', 20], |
||
| 96 | ['renderBulkEditField', 'bulk_edit_custom_box', 10, 2], |
||
| 97 | ['renderLoopRating', 'site-reviews/woocommerce/render/loop/rating', 5], |
||
| 98 | ['renderProductDataPanel', 'woocommerce_product_data_panels'], |
||
| 99 | ['renderQuickEditField', 'quick_edit_custom_box', 5, 2], |
||
| 100 | ['renderSingleProductRating', 'site-reviews/woocommerce/render/single-product/rating', 5], |
||
| 101 | ['renderSingleProductReviews', 'site-reviews/woocommerce/render/single-product-reviews', 5], |
||
| 102 | ['updateProductData', 'woocommerce_admin_process_product_object'], |
||
| 103 | ['updateProductRatingCounts', 'site-reviews/ratings/count/post', 10, 2], |
||
| 104 | ]); |
||
| 105 | $this->hook(RestApiController::class, [ |
||
| 106 | ['filterRestEndpoints', 'rest_endpoints'], |
||
| 107 | ['filterRestNamespaces', 'woocommerce_rest_api_get_rest_namespaces'], |
||
| 108 | ['filterRestPermissions', 'woocommerce_rest_check_permissions', 10, 4], |
||
| 109 | ['filterSqlJoin', 'site-reviews/query/sql/join', 10, 3], |
||
| 110 | ['filterSqlOrderBy', 'site-reviews/query/sql/order-by', 10, 3], |
||
| 111 | ]); |
||
| 127 |