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