| Conditions | 14 |
| Paths | 14 |
| Total Lines | 60 |
| Code Lines | 56 |
| 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 |
||
| 127 | public function parseLongVersion(IEvent $event) { |
||
| 128 | $parsedParameters = $this->getParsedParameters($event->getSubject(), $event->getSubjectParameters()); |
||
| 129 | $richParameters = $this->getRichParameters($event->getSubject(), $event->getSubjectParameters()); |
||
| 130 | |||
| 131 | if ($event->getSubject() === 'created_self') { |
||
| 132 | $event->setParsedSubject($this->l->t('You created %1$s', $parsedParameters)) |
||
| 133 | ->setRichSubject($this->l->t('You created {file1}'), $richParameters) |
||
| 134 | ->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'add-color.svg'))); |
||
| 135 | } else if ($event->getSubject() === 'created_by') { |
||
| 136 | $event->setParsedSubject($this->l->t('%2$s created %1$s', $parsedParameters)) |
||
| 137 | ->setRichSubject($this->l->t('{user1} created {file1}'), $richParameters) |
||
| 138 | ->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'add-color.svg'))); |
||
| 139 | } else if ($event->getSubject() === 'created_public') { |
||
| 140 | $event->setParsedSubject($this->l->t('%1$s was created in a public folder', $parsedParameters)) |
||
| 141 | ->setRichSubject($this->l->t('{file1} was created in a public folder'), $richParameters) |
||
| 142 | ->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'add-color.svg'))); |
||
| 143 | } else if ($event->getSubject() === 'changed_self') { |
||
| 144 | $event->setParsedSubject($this->l->t('You changed %1$s', $parsedParameters)) |
||
| 145 | ->setRichSubject($this->l->t('You changed {file1}'), $richParameters) |
||
| 146 | ->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg'))); |
||
| 147 | } else if ($event->getSubject() === 'changed_by') { |
||
| 148 | $event->setParsedSubject($this->l->t('%2$s changed %1$s', $parsedParameters)) |
||
| 149 | ->setRichSubject($this->l->t('{user1} changed {file1}'), $richParameters) |
||
| 150 | ->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg'))); |
||
| 151 | } else if ($event->getSubject() === 'deleted_self') { |
||
| 152 | $event->setParsedSubject($this->l->t('You deleted %1$s', $parsedParameters)) |
||
| 153 | ->setRichSubject($this->l->t('You deleted {file1}'), $richParameters) |
||
| 154 | ->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'delete-color.svg'))); |
||
| 155 | } else if ($event->getSubject() === 'deleted_by') { |
||
| 156 | $event->setParsedSubject($this->l->t('%2$s deleted %1$s', $parsedParameters)) |
||
| 157 | ->setRichSubject($this->l->t('{user1} deleted {file1}'), $richParameters) |
||
| 158 | ->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'delete-color.svg'))); |
||
| 159 | } else if ($event->getSubject() === 'restored_self') { |
||
| 160 | $event->setParsedSubject($this->l->t('You restored %1$s', $parsedParameters)) |
||
| 161 | ->setRichSubject($this->l->t('You restored {file1}'), $richParameters); |
||
| 162 | } else if ($event->getSubject() === 'restored_by') { |
||
| 163 | $event->setParsedSubject($this->l->t('%2$s restored %1$s', $parsedParameters)) |
||
| 164 | ->setRichSubject($this->l->t('{user1} restored {file1}'), $richParameters); |
||
| 165 | } else if ($event->getSubject() === 'renamed_self') { |
||
| 166 | $event->setParsedSubject($this->l->t('You renamed %2$s to %1$s', $parsedParameters)) |
||
| 167 | ->setRichSubject($this->l->t('You renamed {file2} to {file1}'), $richParameters) |
||
| 168 | ->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg'))); |
||
| 169 | } else if ($event->getSubject() === 'renamed_by') { |
||
| 170 | $event->setParsedSubject($this->l->t('%2$s renamed %3$s to %1$s', $parsedParameters)) |
||
| 171 | ->setRichSubject($this->l->t('{user1} renamed {file2} to {file1}'), $richParameters) |
||
| 172 | ->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg'))); |
||
| 173 | } else if ($event->getSubject() === 'moved_self') { |
||
| 174 | $event->setParsedSubject($this->l->t('You moved %2$s to %1$s', $parsedParameters)) |
||
| 175 | ->setRichSubject($this->l->t('You moved {file2} to {file1}'), $richParameters) |
||
| 176 | ->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg'))); |
||
| 177 | } else if ($event->getSubject() === 'moved_by') { |
||
| 178 | $event->setParsedSubject($this->l->t('%2$s moved %3$s to %1$s', $parsedParameters)) |
||
| 179 | ->setRichSubject($this->l->t('{user1} moved {file2} to {file1}'), $richParameters) |
||
| 180 | ->setIcon($this->url->getAbsoluteURL($this->url->imagePath('files', 'change.svg'))); |
||
| 181 | } else { |
||
| 182 | throw new \InvalidArgumentException(); |
||
| 183 | } |
||
| 184 | |||
| 185 | return $event; |
||
| 186 | } |
||
| 187 | |||
| 277 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.