| Conditions | 2 |
| Paths | 2 |
| Total Lines | 51 |
| Code Lines | 34 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 5 | ||
| 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 |
||
| 115 | protected function setupHelpers( |
||
| 116 | ITask $page, |
||
| 117 | SiteConfiguration $siteConfiguration, |
||
| 118 | PdoDatabase $database, |
||
| 119 | PdoDatabase $notificationsDatabase |
||
| 120 | ) { |
||
| 121 | $page->setSiteConfiguration($siteConfiguration); |
||
| 122 | |||
| 123 | // setup the global database object |
||
| 124 | $page->setDatabase($database); |
||
| 125 | |||
| 126 | // set up helpers and inject them into the page. |
||
| 127 | $httpHelper = new HttpHelper( |
||
| 128 | $siteConfiguration->getUserAgent(), |
||
| 129 | $siteConfiguration->getCurlDisableVerifyPeer() |
||
| 130 | ); |
||
| 131 | |||
| 132 | $page->setEmailHelper(new EmailHelper()); |
||
| 133 | $page->setHttpHelper($httpHelper); |
||
| 134 | $page->setWikiTextHelper(new WikiTextHelper($siteConfiguration, $page->getHttpHelper())); |
||
| 135 | |||
| 136 | if ($siteConfiguration->getLocationProviderApiKey() === null) { |
||
| 137 | $page->setLocationProvider(new FakeLocationProvider()); |
||
| 138 | } |
||
| 139 | else { |
||
| 140 | $page->setLocationProvider(new IpLocationProvider($database, |
||
| 141 | $siteConfiguration->getLocationProviderApiKey())); |
||
| 142 | } |
||
| 143 | |||
| 144 | $page->setXffTrustProvider(new XffTrustProvider($siteConfiguration->getSquidList(), $database)); |
||
| 145 | |||
| 146 | $page->setRdnsProvider(new CachedRDnsLookupProvider($database)); |
||
| 147 | |||
| 148 | $page->setAntiSpoofProvider(new CachedApiAntispoofProvider( |
||
| 149 | $database, |
||
| 150 | $this->getConfiguration()->getMediawikiWebServiceEndpoint(), |
||
| 151 | $httpHelper)); |
||
| 152 | |||
| 153 | $page->setOAuthHelper(new OAuthHelper( |
||
| 154 | $siteConfiguration->getOAuthBaseUrl(), |
||
| 155 | $siteConfiguration->getOAuthConsumerToken(), |
||
| 156 | $siteConfiguration->getOAuthConsumerSecret(), |
||
| 157 | $httpHelper, |
||
| 158 | $siteConfiguration->getMediawikiWebServiceEndpoint() |
||
| 159 | )); |
||
| 160 | |||
| 161 | $page->setNotificationHelper(new IrcNotificationHelper( |
||
| 162 | $siteConfiguration, |
||
| 163 | $notificationsDatabase, |
||
| 164 | $database)); |
||
| 165 | } |
||
| 166 | } |