Conditions | 8 |
Paths | 16 |
Total Lines | 66 |
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 |
||
53 | public function get_settings() { |
||
54 | $settings = array(); |
||
55 | |||
56 | $description = sprintf( __( 'This helps fine tune %s to locate your theme templates directory in order to display content in the same style as your theme.', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ); |
||
57 | |||
58 | if ( is_alnp_pro_version_installed() ) { |
||
59 | $description .= ' ' . sprintf( __( 'Set the location for each post type if they are located in their own template directory. Otherwise just enter the location for %1$sPosts%2$s.', 'auto-load-next-post' ), '<strong>', '</strong>' ); |
||
60 | } |
||
61 | |||
62 | $settings[] = array( |
||
63 | 'title' => $this->label, |
||
64 | 'type' => 'title', |
||
65 | 'desc' => $description, |
||
66 | 'id' => 'templates_options' |
||
67 | ); |
||
68 | |||
69 | $locate_single = alnp_get_template(); |
||
70 | |||
71 | // Only show fallback support option if template location was found. May be required should theme structure fail. |
||
72 | if ( ! empty( $locate_single ) ) { |
||
73 | $settings[] = array( |
||
74 | 'title' => esc_html__( 'Use Fallback?', 'auto-load-next-post' ), |
||
75 | 'desc' => sprintf( __( 'Enabling this will force the use of fallback support should your active theme not have a great structure. %1$sSee help for more information%2$s.', 'auto-load-next-post' ), '<strong class="red">', '</strong>' ), |
||
76 | 'id' => 'auto_load_next_post_use_fallback', |
||
77 | 'default' => 'no', |
||
78 | 'type' => 'checkbox', |
||
79 | 'autoload' => false |
||
80 | ); |
||
81 | } |
||
82 | |||
83 | foreach( alnp_get_post_types() as $post_type ) { |
||
84 | $default = ''; |
||
85 | $readonly = 'no'; |
||
86 | |||
87 | // Checks if the filter has been used already and disable posts only if true. |
||
88 | if ( has_filter( 'alnp_template_location' ) && strtolower( $post_type ) == 'post' ) { |
||
89 | $default = alnp_template_location(); |
||
90 | $readonly = 'yes'; |
||
91 | } |
||
92 | |||
93 | // Checks if theme support provided directory location for post and disable posts only if true. |
||
94 | else if ( ! empty( alnp_get_theme_support( 'directory_post' ) ) && strtolower( $post_type ) == 'post' ) { |
||
95 | $default = alnp_get_theme_support( 'directory_post' ); |
||
96 | $readonly = 'yes'; |
||
97 | } |
||
98 | |||
99 | $settings[] = array( |
||
100 | 'title' => ucfirst( $post_type ), |
||
101 | 'desc' => sprintf( __( 'Enter the folder location where the theme template for %s are stored.', 'auto-load-next-post' ), $post_type ), |
||
102 | 'id' => 'auto_load_next_post_directory_' . strtolower( $post_type ), |
||
103 | 'default' => $default, |
||
104 | 'placeholder' => sprintf( esc_html__( 'e.g. %s', 'auto-load-next-post' ), 'template-parts/' ), |
||
105 | 'readonly' => $readonly, |
||
106 | 'type' => 'text', |
||
107 | 'css' => 'min-width:300px;', |
||
108 | 'autoload' => false |
||
109 | ); |
||
110 | } |
||
111 | |||
112 | $settings[] = array( |
||
113 | 'type' => 'sectionend', |
||
114 | 'id' => 'template_locations' |
||
115 | ); |
||
116 | |||
117 | return $settings; |
||
118 | } // END get_settings() |
||
119 | |||
150 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.