| Conditions | 9 |
| Paths | 7 |
| Total Lines | 57 |
| Code Lines | 35 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| 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 |
||
| 86 | public function widget( $args, $instance ) { |
||
| 87 | |||
| 88 | // Prepare output args. |
||
| 89 | $argument_values = $this->sd->argument_values( $instance ); |
||
| 90 | $argument_values = $this->sd->string_to_bool( $argument_values ); |
||
| 91 | $output = $this->sd->output( $argument_values, $args ); |
||
|
|
|||
| 92 | $no_wrap = ! empty( $argument_values['no_wrap'] ); |
||
| 93 | |||
| 94 | ob_start(); |
||
| 95 | if ( $output && ! $no_wrap ) { |
||
| 96 | |||
| 97 | $class_original = $this->sd->options['widget_ops']['classname']; |
||
| 98 | $class = $this->sd->options['widget_ops']['classname'] . ' sdel-' . $this->sd->get_instance_hash(); |
||
| 99 | |||
| 100 | // Before widget |
||
| 101 | $before_widget = $args['before_widget']; |
||
| 102 | $before_widget = str_replace( $class_original, $class, $before_widget ); |
||
| 103 | $before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this ); |
||
| 104 | $before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->sd->base_id, $before_widget, $args, $instance, $this ); |
||
| 105 | |||
| 106 | // After widget |
||
| 107 | $after_widget = $args['after_widget']; |
||
| 108 | $after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this ); |
||
| 109 | $after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->sd->base_id, $after_widget, $args, $instance, $this ); |
||
| 110 | |||
| 111 | echo $before_widget; |
||
| 112 | |||
| 113 | // elementor strips the widget wrapping div so we check for and add it back if needed |
||
| 114 | if ( $this->is_elementor_widget_output() ) { |
||
| 115 | // Filter class & attrs for elementor widget output. |
||
| 116 | $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this->sd, $this ); |
||
| 117 | $class = apply_filters( 'wp_super_duper_div_classname_' . $this->sd->base_id, $class, $args, $this->sd, $this ); |
||
| 118 | |||
| 119 | $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this->sd, $this ); |
||
| 120 | $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->sd->base_id, $attrs, $args, $this->sd, $this ); |
||
| 121 | |||
| 122 | echo "<span class='" . esc_attr( $class ) . "' " . $attrs . ">"; |
||
| 123 | } |
||
| 124 | |||
| 125 | echo $this->sd->output_title( $args, $instance ); |
||
| 126 | echo $output; |
||
| 127 | if ( $this->is_elementor_widget_output() ) { |
||
| 128 | echo "</span>"; |
||
| 129 | } |
||
| 130 | |||
| 131 | echo $after_widget; |
||
| 132 | } elseif ( $this->sd->is_preview() && $output == '' ) {// if preview show a placeholder if empty |
||
| 133 | $output = $this->sd->preview_placeholder_text( "{{" . $this->base_id . "}}" ); |
||
| 134 | echo $output; |
||
| 135 | } elseif ( $output && $no_wrap ) { |
||
| 136 | echo $output; |
||
| 137 | } |
||
| 138 | $output = ob_get_clean(); |
||
| 139 | |||
| 140 | $output = apply_filters( 'wp_super_duper_widget_output', $output, $instance, $args, $this ); |
||
| 141 | |||
| 142 | echo $output; |
||
| 143 | } |
||
| 211 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.