| Conditions | 1 |
| Paths | 1 |
| Total Lines | 88 |
| 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 |
||
| 28 | public function addParameterInfo( array &$params ) { |
||
|
|
|||
| 29 | global $GLOBALS; |
||
| 30 | |||
| 31 | $params['zoom'] = [ |
||
| 32 | 'type' => 'integer', |
||
| 33 | 'range' => [ 0, 20 ], |
||
| 34 | 'default' => false, |
||
| 35 | 'message' => 'maps-par-zoom' |
||
| 36 | ]; |
||
| 37 | |||
| 38 | $params['defzoom'] = [ |
||
| 39 | 'type' => 'integer', |
||
| 40 | 'range' => [ 0, 20 ], |
||
| 41 | 'default' => self::getDefaultZoom(), |
||
| 42 | 'message' => 'maps-leaflet-par-defzoom' |
||
| 43 | ]; |
||
| 44 | |||
| 45 | $params['layers'] = [ |
||
| 46 | 'aliases' => 'layer', |
||
| 47 | 'type' => 'string', |
||
| 48 | 'values' => array_keys( $GLOBALS['egMapsLeafletAvailableLayers'], true, true ), |
||
| 49 | 'default' => $GLOBALS['egMapsLeafletLayers'], |
||
| 50 | 'message' => 'maps-leaflet-par-layers', |
||
| 51 | 'islist' => true, |
||
| 52 | ]; |
||
| 53 | |||
| 54 | $params['overlaylayers'] = [ |
||
| 55 | 'type' => 'string', |
||
| 56 | 'values' => array_keys( $GLOBALS['egMapsLeafletAvailableOverlayLayers'], true, true ), |
||
| 57 | 'default' => $GLOBALS['egMapsLeafletOverlayLayers'], |
||
| 58 | 'message' => 'maps-leaflet-par-overlaylayers', |
||
| 59 | 'islist' => true, |
||
| 60 | ]; |
||
| 61 | |||
| 62 | $params['resizable'] = [ |
||
| 63 | 'type' => 'boolean', |
||
| 64 | 'default' => $GLOBALS['egMapsResizableByDefault'], |
||
| 65 | 'message' => 'maps-par-resizable' |
||
| 66 | ]; |
||
| 67 | |||
| 68 | $params['enablefullscreen'] = [ |
||
| 69 | 'type' => 'boolean', |
||
| 70 | 'default' => false, |
||
| 71 | 'message' => 'maps-par-enable-fullscreen', |
||
| 72 | ]; |
||
| 73 | |||
| 74 | $params['scrollwheelzoom'] = [ |
||
| 75 | 'type' => 'boolean', |
||
| 76 | 'default' => true, |
||
| 77 | 'message' => 'maps-par-scrollwheelzoom', |
||
| 78 | ]; |
||
| 79 | |||
| 80 | $params['markercluster'] = [ |
||
| 81 | 'type' => 'boolean', |
||
| 82 | 'default' => false, |
||
| 83 | 'message' => 'maps-par-markercluster', |
||
| 84 | ]; |
||
| 85 | |||
| 86 | $params['clustermaxzoom'] = [ |
||
| 87 | 'type' => 'integer', |
||
| 88 | 'default' => 20, |
||
| 89 | 'message' => 'maps-par-clustermaxzoom', |
||
| 90 | ]; |
||
| 91 | |||
| 92 | $params['clusterzoomonclick'] = [ |
||
| 93 | 'type' => 'boolean', |
||
| 94 | 'default' => true, |
||
| 95 | 'message' => 'maps-par-clusterzoomonclick', |
||
| 96 | ]; |
||
| 97 | |||
| 98 | $params['clustermaxradius'] = [ |
||
| 99 | 'type' => 'integer', |
||
| 100 | 'default' => 80, |
||
| 101 | 'message' => 'maps-par-maxclusterradius', |
||
| 102 | ]; |
||
| 103 | |||
| 104 | $params['clusterspiderfy'] = [ |
||
| 105 | 'type' => 'boolean', |
||
| 106 | 'default' => true, |
||
| 107 | 'message' => 'maps-leaflet-par-clusterspiderfy', |
||
| 108 | ]; |
||
| 109 | |||
| 110 | $params['geojson'] = [ |
||
| 111 | 'type' => 'jsonfile', |
||
| 112 | 'default' => '', |
||
| 113 | 'message' => 'maps-displaymap-par-geojson', |
||
| 114 | ]; |
||
| 115 | } |
||
| 116 | |||
| 162 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: