Conditions | 10 |
Paths | 8 |
Total Lines | 47 |
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 |
||
41 | public function gallery_custom_column_content( $column ) { |
||
42 | global $post; |
||
43 | |||
44 | switch ( $column ) { |
||
45 | case FOOGALLERY_CPT_GALLERY . '_template': |
||
46 | $gallery = $this->get_local_gallery( $post ); |
||
47 | echo $gallery->gallery_template_name(); |
||
48 | break; |
||
49 | case FOOGALLERY_CPT_GALLERY . '_count': |
||
50 | $gallery = $this->get_local_gallery( $post ); |
||
51 | echo $gallery->image_count(); |
||
52 | break; |
||
53 | case FOOGALLERY_CPT_GALLERY . '_shortcode': |
||
54 | $gallery = $this->get_local_gallery( $post ); |
||
55 | $shortcode = $gallery->shortcode(); |
||
56 | |||
57 | echo '<input type="text" readonly="readonly" size="' . strlen( $shortcode ) . '" value="' . esc_attr( $shortcode ) . '" class="foogallery-shortcode" />'; |
||
58 | |||
59 | $this->include_clipboard_script = true; |
||
60 | |||
61 | break; |
||
62 | case 'icon': |
||
63 | $gallery = $this->get_local_gallery( $post ); |
||
64 | $html_img = foogallery_find_featured_attachment_thumbnail_html( $gallery, array( |
||
65 | 'width' => 60, |
||
66 | 'height' => 60, |
||
67 | 'force_use_original_thumb' => true |
||
68 | ) ); |
||
69 | if ( $html_img ) { |
||
70 | echo $html_img; |
||
71 | } |
||
72 | break; |
||
73 | case FOOGALLERY_CPT_GALLERY . '_usage': |
||
74 | $gallery = $this->get_local_gallery( $post ); |
||
75 | $posts = $gallery->find_usages(); |
||
76 | if ( $posts && count( $posts ) > 0 ) { |
||
77 | echo '<ul class="ul-disc">'; |
||
78 | foreach ( $posts as $post ) { |
||
79 | echo edit_post_link( $post->post_title, '<li>', '</li>', $post->ID ); |
||
80 | } |
||
81 | echo '</ul>'; |
||
82 | } else { |
||
83 | _e( 'Not used!', 'foogallery' ); |
||
84 | } |
||
85 | break; |
||
86 | } |
||
87 | } |
||
88 | |||
113 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..