| Conditions | 14 |
| Paths | 23 |
| Total Lines | 45 |
| Code Lines | 34 |
| Lines | 24 |
| Ratio | 53.33 % |
| 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 |
||
| 36 | public function parse($language, IEvent $event, IEvent $previousEvent = null) { |
||
| 37 | if ($event->getApp() !== 'dav' || $event->getType() !== 'calendar_todo') { |
||
| 38 | throw new \InvalidArgumentException(); |
||
| 39 | } |
||
| 40 | |||
| 41 | $this->l = $this->languageFactory->get('dav', $language); |
||
| 42 | |||
| 43 | if ($this->activityManager->getRequirePNG()) { |
||
| 44 | $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/checkmark.png'))); |
||
| 45 | } else { |
||
| 46 | $event->setIcon($this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/checkmark.svg'))); |
||
| 47 | } |
||
| 48 | |||
| 49 | View Code Duplication | if ($event->getSubject() === self::SUBJECT_OBJECT_ADD . '_todo') { |
|
| 50 | $subject = $this->l->t('{actor} created todo {todo} in list {calendar}'); |
||
| 51 | } else if ($event->getSubject() === self::SUBJECT_OBJECT_ADD . '_todo_self') { |
||
| 52 | $subject = $this->l->t('You created todo {todo} in list {calendar}'); |
||
| 53 | } else if ($event->getSubject() === self::SUBJECT_OBJECT_DELETE . '_todo') { |
||
| 54 | $subject = $this->l->t('{actor} deleted todo {todo} from list {calendar}'); |
||
| 55 | } else if ($event->getSubject() === self::SUBJECT_OBJECT_DELETE . '_todo_self') { |
||
| 56 | $subject = $this->l->t('You deleted todo {todo} from list {calendar}'); |
||
| 57 | } else if ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_todo') { |
||
| 58 | $subject = $this->l->t('{actor} updated todo {todo} in list {calendar}'); |
||
| 59 | } else if ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_todo_self') { |
||
| 60 | $subject = $this->l->t('You updated todo {todo} in list {calendar}'); |
||
| 61 | |||
| 62 | } else if ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_todo_completed') { |
||
| 63 | $subject = $this->l->t('{actor} solved todo {todo} in list {calendar}'); |
||
| 64 | } else if ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_todo_completed_self') { |
||
| 65 | $subject = $this->l->t('You solved todo {todo} in list {calendar}'); |
||
| 66 | } else if ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_todo_needs_action') { |
||
| 67 | $subject = $this->l->t('{actor} reopened todo {todo} in list {calendar}'); |
||
| 68 | } else if ($event->getSubject() === self::SUBJECT_OBJECT_UPDATE . '_todo_needs_action_self') { |
||
| 69 | $subject = $this->l->t('You reopened todo {todo} in list {calendar}'); |
||
| 70 | } else { |
||
| 71 | throw new \InvalidArgumentException(); |
||
| 72 | } |
||
| 73 | |||
| 74 | $parsedParameters = $this->getParameters($event); |
||
| 75 | $this->setSubjects($event, $subject, $parsedParameters); |
||
| 76 | |||
| 77 | $event = $this->eventMerger->mergeEvents('todo', $event, $previousEvent); |
||
| 78 | |||
| 79 | return $event; |
||
| 80 | } |
||
| 81 | |||
| 145 |