| Conditions | 1 |
| Paths | 1 |
| Total Lines | 77 |
| 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 |
||
| 38 | public static function initExtension() { |
||
| 39 | |||
| 40 | // Load DefaultSettings |
||
| 41 | require_once __DIR__ . '/DefaultSettings.php'; |
||
| 42 | |||
| 43 | define( 'WNBY_VERSION', '1.0.0-alpha' ); |
||
| 44 | |||
| 45 | $GLOBALS['wgExtensionCredits']['others'][] = array( |
||
| 46 | 'path' => __FILE__, |
||
| 47 | 'name' => 'Whats Nearby', |
||
| 48 | 'author' => array( |
||
| 49 | 'James Hong Kong' |
||
| 50 | ), |
||
| 51 | 'url' => 'https://www.semantic-mediawiki.org/wiki/Extension:WhatsNearby', |
||
| 52 | 'descriptionmsg' => 'wnby-desc', |
||
| 53 | 'version' => WNBY_VERSION, |
||
| 54 | 'license-name' => 'GPL-2.0-or-later' |
||
| 55 | ); |
||
| 56 | |||
| 57 | // Register message files |
||
| 58 | $GLOBALS['wgMessagesDirs']['WhatsNearby'] = __DIR__ . '/i18n'; |
||
| 59 | $GLOBALS['wgExtensionMessagesFiles']['WhatsNearbyMagic'] = __DIR__ . '/i18n/WhatsNearby.magic.php'; |
||
| 60 | |||
| 61 | $GLOBALS['wgResourceModules']['ext.whats.nearby.geoip'] = array( |
||
| 62 | 'localBasePath' => __DIR__ , |
||
| 63 | 'remoteExtPath' => 'WhatsNearby', |
||
| 64 | 'position' => 'bottom', |
||
| 65 | 'scripts' => array( |
||
| 66 | 'res/ext.whats.nearby.geoip.js' |
||
| 67 | ), |
||
| 68 | 'targets' => array( |
||
| 69 | 'mobile', |
||
| 70 | 'desktop' |
||
| 71 | ) |
||
| 72 | ); |
||
| 73 | |||
| 74 | $GLOBALS['wgResourceModules']['ext.whats.nearby'] = array( |
||
| 75 | 'localBasePath' => __DIR__ , |
||
| 76 | 'remoteExtPath' => 'WhatsNearby', |
||
| 77 | 'position' => 'bottom', |
||
| 78 | 'styles' => array( |
||
| 79 | 'res/ext.whats.nearby.css' |
||
| 80 | ), |
||
| 81 | 'scripts' => array( |
||
| 82 | 'res/ext.whats.nearby.js' |
||
| 83 | ), |
||
| 84 | 'dependencies' => array( |
||
| 85 | 'mediawiki.api', |
||
| 86 | 'mediawiki.api.parse', |
||
| 87 | 'ext.maps.services', |
||
| 88 | 'onoi.rangeslider', |
||
| 89 | 'onoi.blockUI', |
||
| 90 | 'onoi.md5', |
||
| 91 | 'onoi.blobstore' |
||
| 92 | ), |
||
| 93 | 'messages' => array( |
||
| 94 | 'wnby-geolocation-disabled', |
||
| 95 | 'wnby-geolocation-unsupported', |
||
| 96 | 'wnby-geolocation-unknown-error', |
||
| 97 | 'wnby-geolocation-timeout-error', |
||
| 98 | 'wnby-geolocation-position-unavailable', |
||
| 99 | 'wnby-geolocation-permission-denied', |
||
| 100 | 'wnby-no-fallback-location', |
||
| 101 | 'wnby-geolocation-geoip-fallback', |
||
| 102 | 'wnby-geolocation-geoip-no-fallback', |
||
| 103 | 'wnby-default-fallback-location', |
||
| 104 | 'wnby-invalid-coordinates-format', |
||
| 105 | 'wnby-localcache-use', |
||
| 106 | 'wnby-template-parameter-missing', |
||
| 107 | 'wnby-loading' |
||
| 108 | ), |
||
| 109 | 'targets' => array( |
||
| 110 | 'mobile', |
||
| 111 | 'desktop' |
||
| 112 | ) |
||
| 113 | ); |
||
| 114 | } |
||
| 115 | |||
| 134 |