Conditions | 6 |
Paths | 8 |
Total Lines | 149 |
Code Lines | 82 |
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 |
||
8 | public static function output( $post ) { |
||
9 | global $user_ID; |
||
10 | $post_id = !empty( $post->ID ) ? $post->ID : 0; |
||
11 | $invoice = new WPInv_Invoice( $post_id ); |
||
12 | ?> |
||
13 | <div class="gdmbx2-wrap form-table"> |
||
14 | <div id="gdmbx2-metabox-wpinv_address" class="gdmbx2-metabox gdmbx-field-list wpinv-address gdmbx-row"> |
||
15 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-user-id table-layout"> |
||
16 | <div class="gdmbx-th"> |
||
17 | <label for="post_author_override"><?php _e( 'Customer', 'invoicing' );?></label> |
||
18 | </div> |
||
19 | <div class="gdmbx-td gdmbx-customer-div"> |
||
20 | <?php wpinv_dropdown_users( array( |
||
|
|||
21 | 'name' => 'post_author_override', |
||
22 | 'selected' => empty($post->ID) ? $user_ID : $post->post_author, |
||
23 | 'include_selected' => true, |
||
24 | 'show' => 'user_email', |
||
25 | 'orderby' => 'user_email', |
||
26 | 'class' => 'gdmbx2-text-large' |
||
27 | ) ); ?> |
||
28 | </div> |
||
29 | </div> |
||
30 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-email table-layout" style="display:none"> |
||
31 | <div class="gdmbx-th"><label for="wpinv_email"><?php _e( 'Email', 'invoicing' );?> <span class="required">*</span></label> |
||
32 | </div> |
||
33 | <div class="gdmbx-td"> |
||
34 | <input type="hidden" id="wpinv_new_user" name="wpinv_new_user" value="" /> |
||
35 | <input type="email" class="gdmbx2-text-large" name="wpinv_email" id="wpinv_email" /> |
||
36 | </div> |
||
37 | </div> |
||
38 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-btns table-layout"> |
||
39 | <div class="gdmbx-th"><label><?php _e( 'Actions', 'invoicing' );?></label> |
||
40 | </div> |
||
41 | <div class="gdmbx-td"> |
||
42 | <a id="wpinv-fill-user-details" class="button button-small button-secondary" title="<?php esc_attr_e( 'Fill User Details', 'invoicing' );?>" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-refresh"></i><?php _e( 'Fill User Details', 'invoicing' );?></a> |
||
43 | <a class="wpinv-new-user button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-plus"></i><?php _e( 'Add New User', 'invoicing' );?></a> |
||
44 | <a style="display:none" class="wpinv-new-cancel button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-close"></i><?php _e( 'Cancel', 'invoicing' );?> </a> |
||
45 | </div> |
||
46 | </div> |
||
47 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-first-name table-layout"> |
||
48 | <div class="gdmbx-th"><label for="wpinv_first_name"><?php _e( 'First Name', 'invoicing' );?></label></div> |
||
49 | <div class="gdmbx-td"> |
||
50 | <input type="text" class="gdmbx2-text-large" name="wpinv_first_name" id="wpinv_first_name" value="<?php echo esc_attr( $invoice->first_name );?>" /> |
||
51 | </div> |
||
52 | </div> |
||
53 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-last-name table-layout"> |
||
54 | <div class="gdmbx-th"><label for="wpinv_last_name"><?php _e( 'Last Name', 'invoicing' );?></label></div> |
||
55 | <div class="gdmbx-td"> |
||
56 | <input type="text" class="gdmbx2-text-large" name="wpinv_last_name" id="wpinv_last_name" value="<?php echo esc_attr( $invoice->last_name );?>" /> |
||
57 | </div> |
||
58 | </div> |
||
59 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-company table-layout"> |
||
60 | <div class="gdmbx-th"><label for="wpinv_company"><?php _e( 'Company', 'invoicing' );?></label></div> |
||
61 | <div class="gdmbx-td"> |
||
62 | <input type="text" class="gdmbx2-text-large" name="wpinv_company" id="wpinv_company" value="<?php echo esc_attr( $invoice->company );?>" /> |
||
63 | </div> |
||
64 | </div> |
||
65 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-vat-number table-layout"> |
||
66 | <div class="gdmbx-th"><label for="wpinv_vat_number"><?php _e( 'Vat Number', 'invoicing' );?></label></div> |
||
67 | <div class="gdmbx-td"> |
||
68 | <input type="text" class="gdmbx2-text-large" name="wpinv_vat_number" id="wpinv_vat_number" value="<?php echo esc_attr( $invoice->vat_number );?>" /> |
||
69 | </div> |
||
70 | </div> |
||
71 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-address table-layout"> |
||
72 | <div class="gdmbx-th"><label for="wpinv_address"><?php _e( 'Address', 'invoicing' );?></label></div> |
||
73 | <div class="gdmbx-td"> |
||
74 | <input type="text" class="gdmbx2-text-large" name="wpinv_address" id="wpinv_address" value="<?php echo esc_attr( $invoice->address );?>" /> |
||
75 | </div> |
||
76 | </div> |
||
77 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-city table-layout"> |
||
78 | <div class="gdmbx-th"><label for="wpinv_city"><?php _e( 'City', 'invoicing' );?></label></div> |
||
79 | <div class="gdmbx-td"> |
||
80 | <input type="text" class="gdmbx2-text-large" name="wpinv_city" id="wpinv_city" value="<?php echo esc_attr( $invoice->city );?>" /> |
||
81 | </div> |
||
82 | </div> |
||
83 | <div class="gdmbx-row gdmbx-type-select gdmbx-wpinv-country table-layout"> |
||
84 | <div class="gdmbx-th"><label for="wpinv_country"><?php _e( 'Country', 'invoicing' );?> <span class="wpi-loader"><i class="fa fa-refresh fa-spin"></i></span></label></div> |
||
85 | <div class="gdmbx-td"> |
||
86 | <?php |
||
87 | echo wpinv_html_select( array( |
||
88 | 'options' => array_merge( array( '' => __( 'Choose a country', 'invoicing' ) ), wpinv_get_country_list() ), |
||
89 | 'name' => 'wpinv_country', |
||
90 | 'id' => 'wpinv_country', |
||
91 | 'selected' => $invoice->country, |
||
92 | 'show_option_all' => false, |
||
93 | 'show_option_none' => false, |
||
94 | 'class' => 'gdmbx2-text-large', |
||
95 | 'chosen' => false, |
||
96 | 'placeholder' => __( 'Choose a country', 'invoicing' ), |
||
97 | 'required' => false, |
||
98 | ) ); |
||
99 | ?> |
||
100 | </div> |
||
101 | </div> |
||
102 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-state table-layout"> |
||
103 | <div class="gdmbx-th"><label for="wpinv_state"><?php _e( 'State', 'invoicing' );?></label></div> |
||
104 | <div class="gdmbx-td"> |
||
105 | <?php |
||
106 | $states = wpinv_get_country_states( $invoice->country ); |
||
107 | if( !empty( $states ) ) { |
||
108 | echo wpinv_html_select( array( |
||
109 | 'options' => array_merge( array( '' => __( 'Choose a state', 'invoicing' ) ), $states ), |
||
110 | 'name' => 'wpinv_state', |
||
111 | 'id' => 'wpinv_state', |
||
112 | 'selected' => $invoice->state, |
||
113 | 'show_option_all' => false, |
||
114 | 'show_option_none' => false, |
||
115 | 'class' => 'gdmbx2-text-large', |
||
116 | 'chosen' => false, |
||
117 | 'placeholder' => __( 'Choose a state', 'invoicing' ), |
||
118 | 'required' => false, |
||
119 | ) ); |
||
120 | } else { |
||
121 | echo wpinv_html_text( array( |
||
122 | 'name' => 'wpinv_state', |
||
123 | 'value' => ! empty( $invoice->state ) ? $invoice->state : '', |
||
124 | 'id' => 'wpinv_state', |
||
125 | 'class' => 'gdmbx2-text-large', |
||
126 | 'required' => false, |
||
127 | ) ); |
||
128 | } |
||
129 | ?> |
||
130 | </div> |
||
131 | </div> |
||
132 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-zip table-layout"> |
||
133 | <div class="gdmbx-th"><label for="wpinv_zip"><?php _e( 'Zipcode', 'invoicing' );?></label></div> |
||
134 | <div class="gdmbx-td"> |
||
135 | <input type="text" class="gdmbx2-text-large" name="wpinv_zip" id="wpinv_zip" value="<?php echo esc_attr( $invoice->zip );?>" /> |
||
136 | </div> |
||
137 | </div> |
||
138 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-phone table-layout"> |
||
139 | <div class="gdmbx-th"><label for="wpinv_phone"><?php _e( 'Phone', 'invoicing' );?></label></div> |
||
140 | <div class="gdmbx-td"> |
||
141 | <input type="text" class="gdmbx2-text-large" name="wpinv_phone" id="wpinv_phone" value="<?php echo esc_attr( $invoice->phone );?>" /> |
||
142 | </div> |
||
143 | </div> |
||
144 | <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-ip table-layout"> |
||
145 | <div class="gdmbx-th"><label for="wpinv_ip"><?php _e( 'IP Address', 'invoicing' );?><?php if ($invoice->ip) { ?> |
||
146 | <a href="<?php echo admin_url( 'admin-ajax.php?action=wpinv_ip_geolocation&ip=' . $invoice->ip ); ?>" title="<?php esc_attr_e( 'View IP information', 'invoicing' );?>" target="_blank"><i class="fa fa-external-link" aria-hidden="true"></i></a> |
||
147 | <?php } ?></label></div> |
||
148 | <div class="gdmbx-td"> |
||
149 | <input type="text" class="gdmbx2-text-large" value="<?php echo esc_attr( $invoice->ip );?>" readonly /> |
||
150 | </div> |
||
151 | </div> |
||
152 | </div> |
||
153 | </div> |
||
154 | <?php wp_nonce_field( 'wpinv_save_invoice', 'wpinv_save_invoice' ) ;?> |
||
155 | <?php |
||
156 | } |
||
157 | } |
||
158 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: