Conditions | 7 |
Paths | 2 |
Total Lines | 57 |
Code Lines | 33 |
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 |
||
33 | public function get( $display, $filter = false, $exists = false ) { |
||
34 | $arr = array(); |
||
35 | |||
36 | $blogs = $this->collection->get_filtered( $filter ); |
||
37 | if ( $blogs ) { |
||
38 | $mydata = MslsOptions::create(); |
||
39 | $link = MslsLink::create( $display ); |
||
40 | |||
41 | foreach ( $blogs as $blog ) { |
||
42 | $language = $blog->get_language(); |
||
43 | $url = $mydata->get_current_link(); |
||
44 | $current = ( $blog->userblog_id == $this->collection->get_current_blog_id() ); |
||
45 | |||
46 | if ( $current ) { |
||
47 | $link->txt = $blog->get_description(); |
||
48 | } else { |
||
49 | switch_to_blog( $blog->userblog_id ); |
||
|
|||
50 | |||
51 | if ( $this->is_requirements_not_fulfilled( $mydata, $exists, $language ) ) { |
||
52 | restore_current_blog(); |
||
53 | continue; |
||
54 | } else { |
||
55 | $url = $mydata->get_permalink( $language ); |
||
56 | $link->txt = $blog->get_description(); |
||
57 | } |
||
58 | |||
59 | restore_current_blog(); |
||
60 | } |
||
61 | |||
62 | $link->src = $this->options->get_flag_url( $language ); |
||
63 | $link->alt = $language; |
||
64 | |||
65 | if ( has_filter( 'msls_output_get' ) ) { |
||
66 | /** |
||
67 | * Returns HTML-link for an item of the output-arr |
||
68 | * @since 0.9.8 |
||
69 | * |
||
70 | * @param string $url |
||
71 | * @param MslsLink $link |
||
72 | * @param bool current |
||
73 | */ |
||
74 | $arr[] = ( string ) apply_filters( 'msls_output_get', $url, $link, $current ); |
||
75 | } |
||
76 | else { |
||
77 | $arr[] = sprintf( |
||
78 | '<a href="%s" title="%s"%s>%s</a>', |
||
79 | $url, |
||
80 | $link->txt, |
||
81 | ( $current ? ' class="current_language"' : '' ), |
||
82 | $link |
||
83 | ); |
||
84 | } |
||
85 | } |
||
86 | } |
||
87 | |||
88 | return $arr; |
||
89 | } |
||
90 | |||
163 |