| Conditions | 15 | 
| Paths | 23 | 
| Total Lines | 55 | 
| Code Lines | 40 | 
| 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  | 
            ||
| 72 | 	public function parse($language, IEvent $event, IEvent $previousEvent = null) { | 
            ||
| 73 | 		if ($event->getType() !== 'group_settings') { | 
            ||
| 74 | throw new InvalidArgumentException();  | 
            ||
| 75 | }  | 
            ||
| 76 | |||
| 77 | 		$l = $this->l10n->get('settings', $language); | 
            ||
| 78 | |||
| 79 | $params = $event->getSubjectParameters();  | 
            ||
| 80 | $parsedParameters = [  | 
            ||
| 81 | 'user' => $this->generateUserParameter($params['user']),  | 
            ||
| 82 | 'group' => $this->generateGroupParameter($params['group']),  | 
            ||
| 83 | ];  | 
            ||
| 84 | |||
| 85 | 		if (isset($params['actor'])) { | 
            ||
| 86 | $parsedParameters['actor'] = $this->generateUserParameter($params['actor']);  | 
            ||
| 87 | }  | 
            ||
| 88 | |||
| 89 | 		switch ($event->getSubject()) { | 
            ||
| 90 | case self::ADDED_TO_GROUP:  | 
            ||
| 91 | 				if (isset($parsedParameters['actor'])) { | 
            ||
| 92 | 					if ($this->activityManager->getCurrentUserId() === $params['user']) { | 
            ||
| 93 | 						$subject = $l->t('{actor} added you to group {group}'); | 
            ||
| 94 | 					} elseif (isset($params['actor']) && $this->activityManager->getCurrentUserId() === $params['actor']) { | 
            ||
| 95 | 						$subject = $l->t('You added {user} to group {group}'); | 
            ||
| 96 | 					} else { | 
            ||
| 97 | 						$subject = $l->t('{actor} added {user} to group {group}'); | 
            ||
| 98 | }  | 
            ||
| 99 | 				} else if ($this->activityManager->getCurrentUserId() === $params['user']) { | 
            ||
| 100 | 					$subject = $l->t('An administrator added you to group {group}'); | 
            ||
| 101 | 				} else { | 
            ||
| 102 | 					$subject = $l->t('An administrator added {user} to group {group}'); | 
            ||
| 103 | }  | 
            ||
| 104 | break;  | 
            ||
| 105 | case self::REMOVED_FROM_GROUP:  | 
            ||
| 106 | 				if (isset($parsedParameters['actor'])) { | 
            ||
| 107 | 					if ($this->activityManager->getCurrentUserId() === $params['user']) { | 
            ||
| 108 | 						$subject = $l->t('{actor} removed you from group {group}'); | 
            ||
| 109 | 					} elseif (isset($params['actor']) && $this->activityManager->getCurrentUserId() === $params['actor']) { | 
            ||
| 110 | 						$subject = $l->t('You removed {user} from group {group}'); | 
            ||
| 111 | 					} else { | 
            ||
| 112 | 						$subject = $l->t('{actor} removed {user} from group {group}'); | 
            ||
| 113 | }  | 
            ||
| 114 | 				} else if ($this->activityManager->getCurrentUserId() === $params['user']) { | 
            ||
| 115 | 					$subject = $l->t('An administrator removed you from group {group}'); | 
            ||
| 116 | 				} else { | 
            ||
| 117 | 					$subject = $l->t('An administrator removed {user} from group {group}'); | 
            ||
| 118 | }  | 
            ||
| 119 | break;  | 
            ||
| 120 | default:  | 
            ||
| 121 | throw new InvalidArgumentException();  | 
            ||
| 122 | }  | 
            ||
| 123 | |||
| 124 | $this->setSubjects($event, $subject, $parsedParameters);  | 
            ||
| 125 | |||
| 126 | return $event;  | 
            ||
| 127 | }  | 
            ||
| 203 |