Conditions | 11 |
Paths | 10 |
Total Lines | 54 |
Code Lines | 25 |
Lines | 16 |
Ratio | 29.63 % |
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 |
||
165 | public function send_through_proxy( $uri ) { |
||
166 | /* |
||
167 | * parse_url() only handles http, https type URLs, and will emit E_WARNING on failure. |
||
168 | * This will be displayed on sites, which is not reasonable. |
||
169 | */ |
||
170 | $check = @parse_url($uri); |
||
171 | |||
172 | // Malformed URL, can not process, but this could mean ssl, so let through anyway. |
||
173 | if ( $check === false ) |
||
174 | return true; |
||
175 | |||
176 | $home = parse_url( get_option('siteurl') ); |
||
177 | |||
178 | /** |
||
179 | * Filters whether to preempt sending the request through the proxy server. |
||
180 | * |
||
181 | * Returning false will bypass the proxy; returning true will send |
||
182 | * the request through the proxy. Returning null bypasses the filter. |
||
183 | * |
||
184 | * @since 3.5.0 |
||
185 | * |
||
186 | * @param null $override Whether to override the request result. Default null. |
||
187 | * @param string $uri URL to check. |
||
188 | * @param array $check Associative array result of parsing the URI. |
||
189 | * @param array $home Associative array result of parsing the site URL. |
||
190 | */ |
||
191 | $result = apply_filters( 'pre_http_send_through_proxy', null, $uri, $check, $home ); |
||
192 | if ( ! is_null( $result ) ) |
||
193 | return $result; |
||
194 | |||
195 | View Code Duplication | if ( 'localhost' == $check['host'] || ( isset( $home['host'] ) && $home['host'] == $check['host'] ) ) |
|
196 | return false; |
||
197 | |||
198 | if ( !defined('WP_PROXY_BYPASS_HOSTS') ) |
||
199 | return true; |
||
200 | |||
201 | static $bypass_hosts = null; |
||
202 | static $wildcard_regex = array(); |
||
203 | View Code Duplication | if ( null === $bypass_hosts ) { |
|
204 | $bypass_hosts = preg_split('|,\s*|', WP_PROXY_BYPASS_HOSTS); |
||
205 | |||
206 | if ( false !== strpos(WP_PROXY_BYPASS_HOSTS, '*') ) { |
||
207 | $wildcard_regex = array(); |
||
208 | foreach ( $bypass_hosts as $host ) |
||
209 | $wildcard_regex[] = str_replace( '\*', '.+', preg_quote( $host, '/' ) ); |
||
210 | $wildcard_regex = '/^(' . implode('|', $wildcard_regex) . ')$/i'; |
||
211 | } |
||
212 | } |
||
213 | |||
214 | View Code Duplication | if ( !empty($wildcard_regex) ) |
|
215 | return !preg_match($wildcard_regex, $check['host']); |
||
216 | else |
||
217 | return !in_array( $check['host'], $bypass_hosts ); |
||
218 | } |
||
219 | } |
||
220 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.If the return type contains the type array, this check recommends the use of a more specific type like
String[]
orarray<String>
.