Conditions | 20 |
Paths | 20 |
Total Lines | 85 |
Code Lines | 68 |
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 |
||
41 | public function parse($language, IEvent $event, IEvent $previousEvent = null) { |
||
42 | if ($event->getApp() !== 'analytics') { |
||
43 | throw new InvalidArgumentException(); |
||
44 | } |
||
45 | |||
46 | $parsedSubject = ''; |
||
47 | $ownActivity = ($event->getAuthor() === $this->userId); |
||
48 | |||
49 | switch ($event->getSubject()) { |
||
50 | case ActivityManager::SUBJECT_REPORT_ADD: |
||
51 | $parsedSubject = $this->l10n->t('You created a new report: {report}'); |
||
52 | break; |
||
53 | case ActivityManager::SUBJECT_REPORT_DELETE: |
||
54 | $parsedSubject = $this->l10n->t('You deleted the report {report}'); |
||
55 | break; |
||
56 | case ActivityManager::SUBJECT_REPORT_SHARE: |
||
57 | if ($ownActivity) { |
||
58 | $parsedSubject = $this->l10n->t('You shared the report {report}'); |
||
59 | } else { |
||
60 | $parsedSubject = $event->getSubjectParameters()['author'] . ' ' . $this->l10n->t('shared the report {report} with you'); |
||
61 | } |
||
62 | break; |
||
63 | |||
64 | case ActivityManager::SUBJECT_DATASET_ADD: |
||
65 | $parsedSubject = $this->l10n->t('You created a new dataset: {report}'); |
||
66 | break; |
||
67 | case ActivityManager::SUBJECT_DATASET_DELETE: |
||
68 | $parsedSubject = $this->l10n->t('You deleted the dataset {report}'); |
||
69 | break; |
||
70 | case ActivityManager::SUBJECT_DATASET_SHARE: |
||
71 | if ($ownActivity) { |
||
72 | $parsedSubject = $this->l10n->t('You shared the dataset {report}'); |
||
73 | } else { |
||
74 | $parsedSubject = $event->getSubjectParameters()['author'] . ' ' . $this->l10n->t('shared the dataset {report} with you'); |
||
75 | } |
||
76 | break; |
||
77 | |||
78 | case ActivityManager::SUBJECT_PANORAMA_ADD: |
||
79 | $parsedSubject = $this->l10n->t('You created a new panorama: {report}'); |
||
80 | break; |
||
81 | case ActivityManager::SUBJECT_PANORAMA_DELETE: |
||
82 | $parsedSubject = $this->l10n->t('You deleted the panorama {report}'); |
||
83 | break; |
||
84 | case ActivityManager::SUBJECT_PANORAMA_SHARE: |
||
85 | if ($ownActivity) { |
||
86 | $parsedSubject = $this->l10n->t('You shared the panorama {report}'); |
||
87 | } else { |
||
88 | $parsedSubject = $event->getSubjectParameters()['author'] . ' ' . $this->l10n->t('shared the panorama {report} with you'); |
||
89 | } |
||
90 | break; |
||
91 | |||
92 | case ActivityManager::SUBJECT_DATA_ADD: |
||
93 | if ($ownActivity) { |
||
94 | $parsedSubject = $this->l10n->t('You have added new data to dataset {report}'); |
||
95 | } else { |
||
96 | $parsedSubject = $event->getSubjectParameters()['author'] . ' ' . $this->l10n->t('has added new data to dataset {report}'); |
||
97 | } |
||
98 | break; |
||
99 | case ActivityManager::SUBJECT_DATA_ADD_IMPORT: |
||
100 | if ($ownActivity) { |
||
101 | $parsedSubject = $this->l10n->t('You have imported data in dataset {report}'); |
||
102 | } else { |
||
103 | $parsedSubject = $event->getSubjectParameters()['author'] . ' ' . $this->l10n->t('has imported data in dataset {report}'); |
||
104 | } |
||
105 | break; |
||
106 | case ActivityManager::SUBJECT_DATA_ADD_API: |
||
107 | $parsedSubject = $this->l10n->t('New data has been added to dataset {report} via API'); |
||
108 | break; |
||
109 | case ActivityManager::SUBJECT_DATA_ADD_DATALOAD: |
||
110 | $parsedSubject = $this->l10n->t('New data has been added to dataset {report} via data load'); |
||
111 | break; |
||
112 | } |
||
113 | |||
114 | $event->setRichSubject($parsedSubject, [ |
||
115 | 'report' => [ |
||
116 | 'type' => 'highlight', |
||
117 | 'id' => $event->getObjectId(), |
||
118 | 'name' => '"' . basename($event->getObjectName()) . '"', |
||
119 | 'link' => $this->Url($event->getObjectId()), |
||
120 | ] |
||
121 | ]); |
||
122 | |||
123 | $event->setParsedSubject($parsedSubject) |
||
124 | ->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath($event->getApp(), 'app-dark.svg'))); |
||
125 | return $event; |
||
126 | } |
||
132 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths