Conditions | 1 |
Paths | 1 |
Total Lines | 56 |
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 |
||
16 | public function __construct() { |
||
17 | |||
18 | |||
19 | $options = array( |
||
20 | 'textdomain' => 'invoicing', |
||
21 | 'block-icon' => 'admin-site', |
||
22 | 'block-category'=> 'widgets', |
||
23 | 'block-keywords'=> "['invoicing','buy', 'buy item']", |
||
24 | 'class_name' => __CLASS__, |
||
25 | 'base_id' => 'wpinv_buy', |
||
26 | 'name' => __('Invoicing > Buy Item Button','invoicing'), |
||
27 | 'widget_ops' => array( |
||
28 | 'classname' => 'wpinv-buy-item-class', |
||
29 | 'description' => esc_html__('Displays buy invoicing item button.','invoicing'), |
||
30 | ), |
||
31 | 'arguments' => array( |
||
32 | 'title' => array( |
||
33 | 'title' => __( 'Widget title', 'invoicing' ), |
||
34 | 'desc' => __( 'Enter widget title.', 'invoicing' ), |
||
35 | 'type' => 'text', |
||
36 | 'desc_tip' => true, |
||
37 | 'default' => '', |
||
38 | 'advanced' => false |
||
39 | ), |
||
40 | 'buy_items' => array( |
||
41 | 'title' => __( 'Items to buy', 'invoicing' ), |
||
42 | 'desc' => __( 'Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2 ', 'invoicing' ), |
||
43 | 'type' => 'text', |
||
44 | 'desc_tip' => true, |
||
45 | 'default' => '', |
||
46 | 'placeholder' => __('Items to buy','invoicing'), |
||
47 | 'advanced' => false |
||
48 | ), |
||
49 | 'button_label' => array( |
||
50 | 'title' => __( 'Button Label', 'invoicing' ), |
||
51 | 'desc' => __( 'Enter button label. Default "Buy Now".', 'invoicing' ), |
||
52 | 'type' => 'text', |
||
53 | 'desc_tip' => true, |
||
54 | 'default' => '', |
||
55 | 'advanced' => true |
||
56 | ), |
||
57 | 'post_id' => array( |
||
58 | 'title' => __( 'Post ID', 'invoicing' ), |
||
59 | 'desc' => __( 'Enter related post ID. This is for 3rd party add ons and not mandatory field.', 'invoicing' ), |
||
60 | 'type' => 'number', |
||
61 | 'desc_tip' => true, |
||
62 | 'default' => '', |
||
63 | 'advanced' => true |
||
64 | ), |
||
65 | ) |
||
66 | |||
67 | ); |
||
68 | |||
69 | |||
70 | parent::__construct( $options ); |
||
71 | } |
||
72 | |||
106 | } |
This check looks for calls to
isset(...)
orempty()
on variables that are yet undefined. These calls will always produce the same result and can be removed.This is most likely caused by the renaming of a variable or the removal of a function/method parameter.