| Conditions | 1 |
| Paths | 1 |
| Total Lines | 65 |
| Code Lines | 41 |
| 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 |
||
| 43 | public function addParameterInfo( array &$params ) { |
||
| 44 | global $egMapsOLLayers, $egMapsOLControls, $egMapsResizableByDefault; |
||
| 45 | |||
| 46 | $params['zoom'] = [ |
||
| 47 | 'type' => 'integer', |
||
| 48 | 'range' => [ 0, 19 ], |
||
| 49 | 'default' => self::getDefaultZoom(), |
||
| 50 | 'message' => 'maps-par-zoom', |
||
| 51 | ]; |
||
| 52 | |||
| 53 | $params['controls'] = [ |
||
| 54 | 'default' => $egMapsOLControls, |
||
| 55 | 'values' => self::getControlNames(), |
||
| 56 | 'message' => 'maps-openlayers-par-controls', |
||
| 57 | 'islist' => true, |
||
| 58 | 'tolower' => true, |
||
| 59 | ]; |
||
| 60 | |||
| 61 | $params['layers'] = [ |
||
| 62 | 'default' => $egMapsOLLayers, |
||
| 63 | 'message' => 'maps-openlayers-par-layers', |
||
| 64 | 'manipulatedefault' => true, |
||
| 65 | 'islist' => true, |
||
| 66 | 'tolower' => true, |
||
| 67 | // TODO-customMaps: addCriteria( new CriterionOLLayer() ); |
||
| 68 | ]; |
||
| 69 | |||
| 70 | $params['resizable'] = [ |
||
| 71 | 'type' => 'boolean', |
||
| 72 | 'default' => false, |
||
| 73 | 'manipulatedefault' => false, |
||
| 74 | 'message' => 'maps-par-resizable', |
||
| 75 | ]; |
||
| 76 | |||
| 77 | $params['overlays'] = [ |
||
| 78 | // Default empty array will end up in JS just right without manipulation. |
||
| 79 | 'default' => [], |
||
| 80 | 'manipulatedefault' => false, |
||
| 81 | 'message' => 'maps-openlayers-par-overlays', |
||
| 82 | |||
| 83 | // NOTE: code has moved into @see MapsDisplayMapRenderer |
||
| 84 | // TODO-customMaps: addCriteria( new CriterionOLLayer( ';' ) ); |
||
| 85 | // TODO-customMaps: addManipulations( new MapsParamOLLayers() ); |
||
| 86 | ]; |
||
| 87 | |||
| 88 | $params['resizable'] = [ |
||
| 89 | 'type' => 'boolean', |
||
| 90 | 'default' => $egMapsResizableByDefault, |
||
| 91 | 'message' => 'maps-par-resizable', |
||
| 92 | ]; |
||
| 93 | |||
| 94 | $params['searchmarkers'] = [ |
||
| 95 | 'default' => '', |
||
| 96 | 'message' => 'maps-par-searchmarkers', |
||
| 97 | 'values' => [ 'title', 'all', '' ], |
||
| 98 | 'tolower' => true, |
||
| 99 | ]; |
||
| 100 | |||
| 101 | $params['kml'] = [ |
||
| 102 | 'default' => [], |
||
| 103 | 'message' => 'maps-par-kml', |
||
| 104 | 'islist' => true, |
||
| 105 | // new MapsParamFile() FIXME |
||
| 106 | ]; |
||
| 107 | } |
||
| 108 | |||
| 210 |
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: