| Conditions | 1 | 
| Paths | 1 | 
| Total Lines | 98 | 
| Code Lines | 81 | 
| 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 | ||
| 36 | 		function add_template( $gallery_templates ) { | ||
| 37 | $gallery_templates[] = array( | ||
| 38 | 'slug' => 'masonry', | ||
| 39 | 'name' => __( 'Masonry Image Gallery', 'foogallery' ), | ||
| 40 | 'admin_js' => FOOGALLERY_MASONRY_GALLERY_TEMPLATE_URL . 'js/admin-gallery-masonry.js', | ||
| 41 | 'fields' => array( | ||
| 42 | array( | ||
| 43 | 'id' => 'thumbnail_width', | ||
| 44 | 'title' => __( 'Thumbnail Width', 'foogallery' ), | ||
| 45 | 'desc' => __( 'Choose the width of your thumbnails. Thumbnails will be generated on the fly and cached once generated.', 'foogallery' ), | ||
| 46 | 'type' => 'number', | ||
| 47 | 'class' => 'small-text', | ||
| 48 | 'default' => 150, | ||
| 49 | 'step' => '1', | ||
| 50 | 'min' => '0', | ||
| 51 | ), | ||
| 52 | array( | ||
| 53 | 'id' => 'layout', | ||
| 54 | 'title' => __( 'Masonry Layout', 'foogallery' ), | ||
| 55 | 'desc' => __( 'Choose a fixed width thumb layout, or responsive columns.', 'foogallery' ), | ||
| 56 | 'type' => 'radio', | ||
| 57 | 'choices' => array( | ||
| 58 | 'fixed' => __( 'Fixed Width', 'foogallery' ), | ||
| 59 | '2col' => __( '2 Columns', 'foogallery' ), | ||
| 60 | '3col' => __( '3 Columns', 'foogallery' ), | ||
| 61 | '4col' => __( '4 Columns', 'foogallery' ), | ||
| 62 | '5col' => __( '5 Columns', 'foogallery' ) | ||
| 63 | ), | ||
| 64 | 'spacer' => '<span class="spacer"></span>', | ||
| 65 | 'default' => 'fixed' | ||
| 66 | ), | ||
| 67 | array( | ||
| 68 | 'id' => 'gutter_width', | ||
| 69 | 'title' => __( 'Gutter Width', 'foogallery' ), | ||
| 70 | 'desc' => __( 'The spacing between your thumbnails. Only applicable when using a fixed layout!', 'foogallery' ), | ||
| 71 | 'type' => 'number', | ||
| 72 | 'class' => 'small-text', | ||
| 73 | 'default' => 10, | ||
| 74 | 'step' => '1', | ||
| 75 | 'min' => '0', | ||
| 76 | ), | ||
| 77 | array( | ||
| 78 | 'id' => 'center_align', | ||
| 79 | 'title' => __( 'Image Alignment', 'foogallery' ), | ||
| 80 | 'desc' => __( 'You can choose to center align your images or leave them at the default. Only applicable when using a fixed layout!', 'foogallery' ), | ||
| 81 | 'type' => 'radio', | ||
| 82 | 'choices' => array( | ||
| 83 | 'default' => __( 'Left Alignment', 'foogallery' ), | ||
| 84 | 'center' => __( 'Center Alignment', 'foogallery' ) | ||
| 85 | ), | ||
| 86 | 'spacer' => '<span class="spacer"></span>', | ||
| 87 | 'default' => 'default' | ||
| 88 | ), | ||
| 89 | array( | ||
| 90 | 'id' => 'gutter_percent', | ||
| 91 | 'title' => __( 'Gutter Size', 'foogallery' ), | ||
| 92 | 'desc' => __( 'Choose a gutter size when using responsive columns.', 'foogallery' ), | ||
| 93 | 'type' => 'radio', | ||
| 94 | 'choices' => array( | ||
| 95 | 'no-gutter' => __( 'No Gutter', 'foogallery' ), | ||
| 96 | '' => __( 'Normal Size Gutter', 'foogallery' ), | ||
| 97 | 'large-gutter' => __( 'Larger Gutter', 'foogallery' ) | ||
| 98 | ), | ||
| 99 | 'spacer' => '<span class="spacer"></span>', | ||
| 100 | 'default' => '' | ||
| 101 | ), | ||
| 102 | array( | ||
| 103 | 'id' => 'hover_zoom', | ||
| 104 | 'title' => __( 'Hover Zoom', 'foogallery' ), | ||
| 105 | 'desc' => __( 'The effect that is applied to images when you move your mouse over them.', 'foogallery' ), | ||
| 106 | 'type' => 'radio', | ||
| 107 | 'choices' => array( | ||
| 108 | 'default' => __( 'Zoom Slightly', 'foogallery' ), | ||
| 109 | 'none' => __( 'No Zoom', 'foogallery' ) | ||
| 110 | ), | ||
| 111 | 'spacer' => '<span class="spacer"></span>', | ||
| 112 | 'default' => 'default' | ||
| 113 | ), | ||
| 114 | array( | ||
| 115 | 'id' => 'thumbnail_link', | ||
| 116 | 'title' => __( 'Thumbnail Link', 'foogallery' ), | ||
| 117 | 'default' => 'image' , | ||
| 118 | 'type' => 'thumb_link', | ||
| 119 | 'spacer' => '<span class="spacer"></span>', | ||
| 120 | 'desc' => __( 'You can choose to link each thumbnail to the full size image, or to the image\'s attachment page, or you can choose to not link to anything.', 'foogallery' ), | ||
| 121 | ), | ||
| 122 | array( | ||
| 123 | 'id' => 'lightbox', | ||
| 124 | 'title' => __( 'Lightbox', 'foogallery' ), | ||
| 125 | 'desc' => __( 'Choose which lightbox you want to display images with. The lightbox will only work if you set the thumbnail link to "Full Size Image".', 'foogallery' ), | ||
| 126 | 'type' => 'lightbox', | ||
| 127 | ), | ||
| 128 | ), | ||
| 129 | ); | ||
| 130 | |||
| 131 | |||
| 132 | return $gallery_templates; | ||
| 133 | } | ||
| 134 | |||
| 161 | } | 
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.