| Conditions | 6 |
| Paths | 4 |
| Total Lines | 78 |
| Code Lines | 59 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 109 | public function portletView($itemId = null) |
||
| 110 | { |
||
| 111 | $App = $this->App(); |
||
| 112 | $W = bab_Widgets(); |
||
| 113 | $notifSet = $App->NotificationSet(); |
||
| 114 | |||
| 115 | $box = $W->FlowItems()->setIconFormat(24, 'center'); |
||
| 116 | if(isset($itemId)){ |
||
| 117 | $box->setId($itemId); |
||
| 118 | } |
||
| 119 | $notifs = $notifSet->selectUserNotifications(); |
||
| 120 | $nbNotif = $notifs->count(); |
||
| 121 | $notifIcon = 'icon '; |
||
| 122 | $notifClass = 'label label-default'; |
||
| 123 | $sizePolicy = 'notificationBtn'; |
||
| 124 | |||
| 125 | $box->addItem($btnWidget = $W->FlexItems()) |
||
| 126 | ->setIcon(16, 'left'); |
||
| 127 | if($nbNotif > 0){ |
||
| 128 | $btnWidget->addItem($W->Label($nbNotif) |
||
| 129 | ->addClass('notificationNumber')); |
||
| 130 | $btnWidget->addClass('notificationDisplayButton'); |
||
| 131 | $notifIcon .= 'webapp-bell-ringing-o'; |
||
| 132 | $sizePolicy .= ' hasNotification'; |
||
| 133 | |||
| 134 | $notificationBox = $W->FlexItems($W->Html('') |
||
| 135 | ->addClass('notificationListArrow'), $W->Html('') |
||
| 136 | ->addClass('notificationListArrowInside')) |
||
| 137 | ->setSizePolicy('notificationsList') |
||
| 138 | ->setDirection(WidgetFlexLayout::FLEX_DIRECTION_COL); |
||
| 139 | |||
| 140 | $notificationBox->addItems($W->FlexItems($W->Title($App->translate('Notifications'), 3), $W->Link('', $this->proxy() |
||
| 141 | ->personalConfiguration()) |
||
| 142 | ->setOpenMode(WidgetLink::OPEN_DIALOG) |
||
| 143 | ->addClass('icon webapp-gear') |
||
| 144 | ->setTitle($App->translate('Notifications configuration'))) |
||
| 145 | ->addClass('notificationBoxTitle') |
||
| 146 | ->setJustifyContent(WidgetFlexLayout::FLEX_JUSTIFY_CONTENT_SPACE_BETWEEN), $notificationBoxElements = $W->FlexItems() |
||
| 147 | ->addClass('notificationBoxElements') |
||
| 148 | ->setDirection(WidgetFlexLayout::FLEX_DIRECTION_COL)); |
||
| 149 | |||
| 150 | foreach ($notifs as $notif){ |
||
| 151 | $notificationBoxElements->addItem($W->Link($el = $W->FlexItems($W->Label($notif->title) |
||
| 152 | ->addClass('notificationElementTitle'), $W->Label(date('d/m/Y H:i', strtotime($notif->createdOn))) |
||
| 153 | ->addClass('notificationElementDate')) |
||
| 154 | ->setDirection(WidgetFlexLayout::FLEX_DIRECTION_COL), $this->proxy() |
||
| 155 | ->display($notif->id)) |
||
| 156 | ->addClass('notificationBoxElement') |
||
| 157 | ->setOpenMode(WidgetLink::OPEN_DIALOG)); |
||
| 158 | if(! empty($notif->description)){ |
||
| 159 | $desc = $notif->description; |
||
| 160 | if(strlen($desc) > 40){ |
||
| 161 | $desc = trim(substr($desc, 0, 40)) . '...'; |
||
| 162 | } |
||
| 163 | $el->addItem($W->Label($desc) |
||
| 164 | ->addClass('notificationElementDescription'), 1); |
||
| 165 | } |
||
| 166 | } |
||
| 167 | |||
| 168 | $notificationBoxElements->addItem($W->Label($App->translate('Show more')) |
||
| 169 | ->addClass('notificationElementShowMore')); |
||
| 170 | |||
| 171 | $box->addItem($notificationBox); |
||
| 172 | } |
||
| 173 | else{ |
||
| 174 | $notifIcon .= 'webapp-bell-o'; |
||
| 175 | } |
||
| 176 | |||
| 177 | $btnWidget->addClass($notifIcon)->addClass($notifClass); |
||
| 178 | $btnWidget->setSizePolicy($sizePolicy); |
||
| 179 | |||
| 180 | $box->setReloadAction($this->proxy() |
||
| 181 | ->portletView($box->getId())); |
||
| 182 | |||
| 183 | $box->addClass(AppNotification::NOTIFICATION_PORTLET_CLASS); |
||
| 184 | $box->addClass('notificationsBox'); |
||
| 185 | |||
| 186 | return $box; |
||
| 187 | } |
||
| 222 |
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