| Conditions | 12 |
| Paths | 7 |
| Total Lines | 29 |
| 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 |
||
| 73 | public static function onGroupNotify( SWLGroup $group, array $userIDs, SWLChangeSet $changes ) { |
||
| 74 | global $egSWLMailPerChange, $egSWLMaxMails; |
||
| 75 | |||
| 76 | foreach ( $userIDs as $userID ) { |
||
| 77 | $user = User::newFromId( $userID ); |
||
| 78 | |||
| 79 | if ( $user->getOption( 'swl_email', false ) ) { |
||
| 80 | if ( $user->getName() != $changes->getEdit()->getUser()->getName() || $GLOBALS['egSWLEnableSelfNotify'] ) { |
||
| 81 | if ( !method_exists( 'Sanitizer', 'validateEmail' ) || Sanitizer::validateEmail( $user->getEmail() ) ) { |
||
| 82 | $lastNotify = $user->getOption( 'swl_last_notify' ); |
||
| 83 | $lastWatch = $user->getOption( 'swl_last_watch' ); |
||
| 84 | |||
| 85 | if ( is_null( $lastNotify ) || is_null( $lastWatch ) || $lastNotify < $lastWatch ) { |
||
| 86 | $mailCount = $user->getOption( 'swl_mail_count', 0 ); |
||
| 87 | |||
| 88 | if ( $egSWLMailPerChange || $mailCount < $egSWLMaxMails ) { |
||
| 89 | SWLEmailer::notifyUser( $group, $user, $changes, $egSWLMailPerChange ); |
||
| 90 | $user->setOption( 'swl_last_notify', wfTimestampNow() ); |
||
| 91 | $user->setOption( 'swl_mail_count', $mailCount + 1 ); |
||
| 92 | $user->saveSettings(); |
||
| 93 | } |
||
| 94 | } |
||
| 95 | } |
||
| 96 | } |
||
| 97 | } |
||
| 98 | } |
||
| 99 | |||
| 100 | return true; |
||
| 101 | } |
||
| 102 | |||
| 123 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.