Conditions | 3 |
Paths | 1 |
Total Lines | 55 |
Code Lines | 33 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
34 | protected function getParameterDefinitions() { |
||
35 | $params = parent::getParameterDefinitions(); |
||
36 | |||
37 | // map extent for extents bound object: |
||
38 | $params['topextent'] = [ |
||
39 | 'type' => 'float', |
||
40 | 'aliases' => [ 'upperbound', 'topbound' ], |
||
41 | 'message' => 'maps-displaymap-par-coordinates', // TODO-customMaps: create a message |
||
42 | ]; |
||
43 | |||
44 | $params['rightextent'] = [ |
||
45 | 'type' => 'float', |
||
46 | 'aliases' => [ 'rightbound' ], |
||
47 | 'message' => 'maps-displaymap-par-coordinates', // TODO-customMaps: create a message |
||
48 | ]; |
||
49 | |||
50 | $params['bottomextent'] = [ |
||
51 | 'type' => 'float', |
||
52 | 'aliases' => [ 'lowerbound', 'bottombound' ], |
||
53 | 'message' => 'maps-displaymap-par-coordinates', // TODO-customMaps: create a message |
||
54 | ]; |
||
55 | |||
56 | $params['leftextent'] = [ |
||
57 | 'type' => 'float', |
||
58 | 'aliases' => [ 'leftbound' ], |
||
59 | 'message' => 'maps-displaymap-par-coordinates', // TODO-customMaps: create a message |
||
60 | ]; |
||
61 | |||
62 | // image-source information: |
||
63 | $params['source'] = [ |
||
64 | // TODO-customMaps: addCriteria( new CriterionIsImage() ) |
||
65 | 'message' => 'maps-displaymap-par-coordinates', // TODO-customMaps: create a message |
||
66 | 'post-format' => function( $source ) { |
||
67 | $imageUrl = MapsMapper::getFileUrl( $source ); |
||
|
|||
68 | |||
69 | global $egMapsAllowExternalImages; |
||
70 | if( $imageUrl === '' && $egMapsAllowExternalImages ) { |
||
71 | return $source; |
||
72 | } |
||
73 | return $imageUrl; |
||
74 | } |
||
75 | ]; |
||
76 | |||
77 | $params['width'] = [ |
||
78 | 'type' => 'float', |
||
79 | 'message' => 'maps-displaymap-par-coordinates', // TODO-customMaps: create a message |
||
80 | ]; |
||
81 | |||
82 | $params['height'] = [ |
||
83 | 'type' => 'float', |
||
84 | 'message' => 'maps-displaymap-par-coordinates', // TODO-customMaps: create a message |
||
85 | ]; |
||
86 | |||
87 | return $params; |
||
88 | } |
||
89 | |||
199 |
This method has been deprecated.