Conditions | 4 |
Paths | 4 |
Total Lines | 77 |
Code Lines | 48 |
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 |
||
76 | public function prepare(INotification $notification, string $languageCode): INotification |
||
77 | { |
||
78 | if ($notification->getApp() !== 'analytics') { |
||
79 | // Not my app => throw |
||
80 | throw new InvalidArgumentException('Unknown app'); |
||
81 | } |
||
82 | |||
83 | // Read the language from the notification |
||
84 | $l = $this->l10nFactory->get('analytics', $languageCode); |
||
85 | $parsedSubject = ''; |
||
86 | |||
87 | $parameters = $notification->getSubjectParameters(); |
||
88 | |||
89 | switch ($notification->getObjectType()) { |
||
90 | case NotificationManager::SUBJECT_THRESHOLD: |
||
91 | $parsedSubject = $l->t("Report '{report}': {subject} reached the threshold of {rule} {value}"); |
||
92 | $link = $this->urlGenerator->linkToRouteAbsolute('analytics.page.index') . '#/r/' . $notification->getObjectId(); |
||
93 | |||
94 | $notification->setRichSubject( |
||
95 | $parsedSubject, |
||
96 | [ |
||
97 | 'report' => [ |
||
98 | 'type' => 'highlight', |
||
99 | 'id' => $notification->getObjectId(), |
||
100 | 'name' => $parameters['report'], |
||
101 | 'link' => $link, |
||
102 | ], |
||
103 | 'subject' => [ |
||
104 | 'type' => 'highlight', |
||
105 | 'id' => $notification->getObjectId(), |
||
106 | 'name' => $parameters['subject'], |
||
107 | ], |
||
108 | 'rule' => [ |
||
109 | 'type' => 'highlight', |
||
110 | 'id' => $notification->getObjectId(), |
||
111 | 'name' => $parameters['rule'], |
||
112 | ], |
||
113 | 'value' => [ |
||
114 | 'type' => 'highlight', |
||
115 | 'id' => $notification->getObjectId(), |
||
116 | 'name' => $parameters['value'], |
||
117 | ], |
||
118 | ] |
||
119 | ); |
||
120 | |||
121 | break; |
||
122 | case NotificationManager::DATALOAD_ERROR: |
||
123 | $parsedSubject = $l->t("Error during data load \"{dataloadName}\" for data set \"{datasetName}\"" ); |
||
124 | $link = $this->urlGenerator->linkToRouteAbsolute('analytics.page.index') . 'a/#/r/' . $notification->getObjectId(); |
||
125 | |||
126 | $notification->setRichSubject( |
||
127 | $parsedSubject, |
||
128 | [ |
||
129 | 'dataloadName' => [ |
||
130 | 'type' => 'highlight', |
||
131 | 'id' => $notification->getObjectId(), |
||
132 | 'name' => $parameters['dataloadName'], |
||
133 | ], |
||
134 | 'datasetName' => [ |
||
135 | 'type' => 'highlight', |
||
136 | 'id' => $notification->getObjectId(), |
||
137 | 'name' => $parameters['datasetName'], |
||
138 | 'link' => $link, |
||
139 | ] |
||
140 | ] |
||
141 | ); |
||
142 | |||
143 | break; |
||
144 | default: // legacy due to switch to subject field filled with an id for notification removal |
||
145 | //$parsedSubject = $l->t("Report '{report}': {subject} reached the threshold of {rule} {value}"); |
||
146 | //$link = $this->urlGenerator->linkToRouteAbsolute('analytics.page.index') . '#/r/' . $notification->getObjectId(); |
||
147 | } |
||
148 | |||
149 | |||
150 | $notification->setIcon($this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('analytics', 'app-dark.svg'))); |
||
151 | $this->setParsedSubjectFromRichSubject($notification); |
||
152 | return $notification; |
||
153 | } |
||
173 |
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