| Conditions | 12 |
| Paths | 21 |
| Total Lines | 39 |
| Code Lines | 30 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 1 | 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 |
||
| 69 | public static function getEditElementSourceButton(?ElementInterface $element, array $attributes = [], ?string $size = null): string |
||
| 70 | { |
||
| 71 | if (empty($element)) { |
||
| 72 | return ''; |
||
| 73 | } |
||
| 74 | $html = ''; |
||
| 75 | if ($element instanceof Entry) { |
||
| 76 | if (!empty($element->typeId)) { |
||
| 77 | $html .= static::_getEditSourceButtonHtml( |
||
| 78 | label: 'Edit entry type', |
||
| 79 | path: "settings/entry-types/$element->typeId", |
||
| 80 | attributes: [ |
||
| 81 | 'data-type-id' => $element->typeId, |
||
| 82 | ], |
||
| 83 | size: $size |
||
| 84 | ); |
||
| 85 | } |
||
| 86 | if (!empty($element->sectionId)) { |
||
| 87 | $html .= static::_getEditSourceButtonHtml(label: 'Edit section', path: "settings/sections/$element->sectionId", size: $size); |
||
| 88 | } |
||
| 89 | } else if ($element instanceof Asset) { |
||
| 90 | $html = static::_getEditSourceButtonHtml(label: 'Edit volume', path: "settings/assets/volumes/{$element->volumeId}", size: $size); |
||
| 91 | } else if ($element instanceof GlobalSet) { |
||
| 92 | $html = static::_getEditSourceButtonHtml(label: 'Edit global set', path: "settings/globals/{$element->id}", size: $size); |
||
| 93 | } else if ($element instanceof User) { |
||
| 94 | $html = static::_getEditSourceButtonHtml(label: 'Edit settings', path: 'settings/users/fields', size: $size); |
||
| 95 | } else if ($element instanceof Category) { |
||
| 96 | $html = static::_getEditSourceButtonHtml(label: 'Edit category group', path: "settings/categories/{$element->groupId}", size: $size); |
||
| 97 | } else if (class_exists(Product::class) && $element instanceof Product) { |
||
| 98 | $html = static::_getEditSourceButtonHtml(label: 'Edit product type', path: "commerce/settings/producttypes/{$element->typeId}", size: $size); |
||
| 99 | } |
||
| 100 | if (empty($html)) { |
||
| 101 | return ''; |
||
| 102 | } |
||
| 103 | return Html::tag('div', $html, [ |
||
| 104 | ...$attributes, |
||
| 105 | 'class' => [ |
||
| 106 | 'cp-field-inspect-sourcebtn-wrapper flex', |
||
| 107 | ...$attributes['class'] ?? [], |
||
| 108 | ], |
||
| 133 |
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