| Conditions | 10 |
| Paths | 1 |
| Total Lines | 107 |
| Code Lines | 73 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 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 |
||
| 57 | public function configure(DataTable $dataTable, array $options) |
||
| 58 | { |
||
| 59 | $dataTable->add('symbol', TextColumn::class, [ |
||
| 60 | 'label' => '', |
||
| 61 | 'render' => function ($value, AbstractLogEntry $context) { |
||
| 62 | switch ($context->getLevelString()) { |
||
| 63 | case LogLevel::DEBUG: |
||
| 64 | $symbol = 'fa-bug'; |
||
| 65 | break; |
||
| 66 | case LogLevel::INFO: |
||
| 67 | $symbol = 'fa-info'; |
||
| 68 | break; |
||
| 69 | case LogLevel::NOTICE: |
||
| 70 | $symbol = 'fa-flag'; |
||
| 71 | break; |
||
| 72 | case LogLevel::WARNING: |
||
| 73 | $symbol = 'fa-exclamation-circle'; |
||
| 74 | break; |
||
| 75 | case LogLevel::ERROR: |
||
| 76 | $symbol = 'fa-exclamation-triangle'; |
||
| 77 | break; |
||
| 78 | case LogLevel::CRITICAL: |
||
| 79 | $symbol = 'fa-bolt'; |
||
| 80 | break; |
||
| 81 | case LogLevel::ALERT: |
||
| 82 | $symbol = 'fa-radiation'; |
||
| 83 | break; |
||
| 84 | case LogLevel::EMERGENCY: |
||
| 85 | $symbol = 'fa-skull-crossbones'; |
||
| 86 | break; |
||
| 87 | default: |
||
| 88 | $symbol = 'fa-question-circle'; |
||
| 89 | break; |
||
| 90 | } |
||
| 91 | |||
| 92 | return sprintf('<i class="fas fa-fw %s"></i>', $symbol); |
||
| 93 | } |
||
| 94 | ]); |
||
| 95 | |||
| 96 | $dataTable->add('id', TextColumn::class, [ |
||
| 97 | 'label' => $this->translator->trans('log.id'), |
||
| 98 | 'visible' => false, |
||
| 99 | ]); |
||
| 100 | |||
| 101 | $dataTable->add('timestamp', LocaleDateTimeColumn::class, [ |
||
| 102 | 'label' => $this->translator->trans('log.timestamp'), |
||
| 103 | 'timeFormat' => 'medium' |
||
| 104 | ]); |
||
| 105 | |||
| 106 | $dataTable->add('type', TextColumn::class, [ |
||
| 107 | 'label' => $this->translator->trans('log.type'), |
||
| 108 | 'propertyPath' => 'type', |
||
| 109 | 'render' => function (string $value, AbstractLogEntry $context) { |
||
| 110 | return $this->translator->trans('log.type.' . $value); |
||
| 111 | } |
||
| 112 | |||
| 113 | ]); |
||
| 114 | |||
| 115 | $dataTable->add('level', TextColumn::class, [ |
||
| 116 | 'label' => $this->translator->trans('log.level'), |
||
| 117 | 'propertyPath' => 'levelString', |
||
| 118 | 'render' => function (string $value, AbstractLogEntry $context) { |
||
| 119 | return $value; |
||
| 120 | } |
||
| 121 | ]); |
||
| 122 | |||
| 123 | |||
| 124 | $dataTable->add('user', TextColumn::class, [ |
||
| 125 | 'label' => $this->translator->trans('log.user'), |
||
| 126 | 'render' => function ($value, AbstractLogEntry $context) { |
||
| 127 | $user = $context->getUser(); |
||
| 128 | return sprintf( |
||
| 129 | '<a href="%s">%s</a>', |
||
| 130 | $this->urlGenerator->generate('user_info', ['id' => $user->getID()]), |
||
| 131 | $user->getFullName(true) |
||
| 132 | ); |
||
| 133 | } |
||
| 134 | ]); |
||
| 135 | |||
| 136 | |||
| 137 | |||
| 138 | $dataTable->add('target_type', TextColumn::class, [ |
||
| 139 | 'label' => $this->translator->trans('log.target_type'), |
||
| 140 | 'visible' => false, |
||
| 141 | 'render' => function ($value, AbstractLogEntry $context) { |
||
| 142 | $class = $context->getTargetClass(); |
||
| 143 | if ($class !== null) { |
||
| 144 | return $this->elementTypeNameGenerator->getLocalizedTypeLabel($class); |
||
| 145 | } |
||
| 146 | return ''; |
||
| 147 | } |
||
| 148 | ]); |
||
| 149 | |||
| 150 | $dataTable->add('target', LogEntryTargetColumn::class, [ |
||
| 151 | 'label' => $this->translator->trans('log.target') |
||
| 152 | ]); |
||
| 153 | |||
| 154 | $dataTable->add('extra', LogEntryExtraColumn::class, [ |
||
| 155 | 'label' => $this->translator->trans('log.extra') |
||
| 156 | ]); |
||
| 157 | |||
| 158 | $dataTable->addOrderBy('timestamp', DataTable::SORT_DESCENDING); |
||
| 159 | |||
| 160 | $dataTable->createAdapter(ORMAdapter::class, [ |
||
| 161 | 'entity' => AbstractLogEntry::class, |
||
| 162 | 'query' => function (QueryBuilder $builder): void { |
||
| 163 | $this->getQuery($builder); |
||
| 164 | }, |
||
| 175 | } |
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