Conditions | 10 |
Paths | 7 |
Total Lines | 35 |
Code Lines | 24 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | 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 |
||
20 | public function filterFieldAfter(array $fields, ReviewForm $form): array |
||
21 | { |
||
22 | $assignedPostId = Cast::toInt($form->args->assigned_posts); |
||
23 | if (empty($assignedPostId)) { |
||
24 | return $fields; |
||
25 | } |
||
26 | if (!$product = Woocommerce::getInstance()->getProduct($assignedPostId)) { |
||
27 | return $fields; |
||
28 | } |
||
29 | if (!is_user_logged_in() || Woocommerce::getInstance()->isBannedUser()) { |
||
30 | return $fields; |
||
31 | } |
||
32 | if (apply_filters('wlr_hide_product_review_message', false, [])) { |
||
33 | return $fields; |
||
34 | } |
||
35 | foreach ($fields as $field) { |
||
36 | if ('content' !== $field->original_name) { |
||
37 | continue; |
||
38 | } |
||
39 | $rewardsList = EarnCampaign::getInstance()->getActionEarning(['product_review'], [ |
||
40 | 'is_calculate_based' => 'product', |
||
41 | 'product' => $product, |
||
42 | 'product_id' => $assignedPostId, |
||
43 | 'user_email' => Woocommerce::getInstance()->get_login_user_email(), |
||
44 | ]); |
||
45 | $messages = [$field->after]; |
||
46 | foreach ($rewardsList as $action => $rewards) { |
||
47 | foreach ($rewards as $key => $reward) { |
||
48 | $messages[] = $reward['messages'] ?? ''; |
||
49 | } |
||
50 | } |
||
51 | $field->after = implode('<br/>', array_filter($messages)); |
||
52 | break; |
||
53 | } |
||
54 | return $fields; |
||
55 | } |
||
108 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths