| Conditions | 14 |
| Paths | 1536 |
| Total Lines | 70 |
| Code Lines | 54 |
| 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 |
||
| 27 | public static function google_map($ee_gmaps_opts) |
||
| 28 | { |
||
| 29 | |||
| 30 | $ee_map_width = ! empty($ee_gmaps_opts['ee_map_width']) ? $ee_gmaps_opts['ee_map_width'] : '300'; |
||
| 31 | $ee_map_height = ! empty($ee_gmaps_opts['ee_map_height']) ? $ee_gmaps_opts['ee_map_height'] : '185'; |
||
| 32 | $ee_map_zoom = ! empty($ee_gmaps_opts['ee_map_zoom']) ? $ee_gmaps_opts['ee_map_zoom'] : '12'; |
||
| 33 | $ee_map_nav_display = ! empty($ee_gmaps_opts['ee_map_nav_display']) ? 'true' : 'false'; |
||
| 34 | $ee_map_nav_size = ! empty($ee_gmaps_opts['ee_map_nav_size']) |
||
| 35 | ? $ee_gmaps_opts['ee_map_nav_size'] |
||
| 36 | : 'default'; |
||
| 37 | $ee_map_type_control = ! empty($ee_gmaps_opts['ee_map_type_control']) |
||
| 38 | ? $ee_gmaps_opts['ee_map_type_control'] |
||
| 39 | : 'default'; |
||
| 40 | $static_url = ! empty($ee_gmaps_opts['ee_static_url']) ? $ee_gmaps_opts['ee_static_url'] : false; |
||
| 41 | |||
| 42 | if (! empty($ee_gmaps_opts['ee_map_align'])) { |
||
| 43 | switch ($ee_gmaps_opts['ee_map_align']) { |
||
| 44 | case "left": |
||
| 45 | $map_align = 'ee-gmap-align-left left'; |
||
| 46 | break; |
||
| 47 | case "right": |
||
| 48 | $map_align = 'ee-gmap-align-right right'; |
||
| 49 | break; |
||
| 50 | case "center": |
||
| 51 | $map_align = 'ee-gmap-align-center center'; |
||
| 52 | break; |
||
| 53 | case "none": |
||
| 54 | default: |
||
| 55 | $map_align = 'ee-gmap-align-none'; |
||
| 56 | } |
||
| 57 | } else { |
||
| 58 | $map_align = 'ee-gmap-align-none'; |
||
| 59 | } |
||
| 60 | |||
| 61 | |||
| 62 | // Determine whether user has set a hardoded url to use and |
||
| 63 | // if so display a Google static iframe map else run V3 api |
||
| 64 | if ($static_url) { |
||
| 65 | $html = '<div class="ee-gmap-iframewrap ee-gmap-wrapper ' . $map_align . '">'; |
||
| 66 | $html .= '<iframe src="' . $static_url . '&output=embed"' |
||
| 67 | . ' style="width: ' . $ee_map_width . 'px; height: ' . $ee_map_height . 'px;"' |
||
| 68 | . ' frameborder="0" scrolling="no">'; |
||
| 69 | $html .= '</iframe>'; |
||
| 70 | $html .= '<a href="' . $static_url . '">View Large map</a>'; |
||
| 71 | $html .= '</div>'; |
||
| 72 | return $html; |
||
| 73 | |||
| 74 | } else { |
||
| 75 | EEH_Maps::$gmap_vars[$ee_gmaps_opts['map_ID']] = array( |
||
| 76 | 'map_ID' => $ee_gmaps_opts['map_ID'], |
||
| 77 | 'ee_map_zoom' => $ee_map_zoom, |
||
| 78 | 'ee_map_nav_display' => $ee_map_nav_display, |
||
| 79 | 'ee_map_nav_size' => $ee_map_nav_size, |
||
| 80 | 'ee_map_type_control' => $ee_map_type_control, |
||
| 81 | 'location' => $ee_gmaps_opts['location'], |
||
| 82 | ); |
||
| 83 | |||
| 84 | $style = 'width: ' . $ee_map_width . 'px; height: ' . $ee_map_height . 'px;'; |
||
| 85 | $html = '<div class="ee-gmap-wrapper ' . $map_align . '">' |
||
| 86 | . '<div class="ee-gmap" id="map_canvas_' . $ee_gmaps_opts['map_ID'] . '"' |
||
| 87 | . ' style="' . $style . '"></div>' |
||
| 88 | . '</div>'; |
||
| 89 | |||
| 90 | wp_enqueue_script('gmap_api'); |
||
| 91 | wp_enqueue_script('ee_gmap'); |
||
| 92 | add_action('wp_footer', array('EEH_Maps', 'footer_enqueue_script')); |
||
| 93 | |||
| 94 | return $html; |
||
| 95 | } // end auto map or static url map check |
||
| 96 | } |
||
| 97 | |||
| 189 | // Location: /helpers/EEH_Maps.helper.php |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.