| Conditions | 13 |
| Paths | 12 |
| Total Lines | 52 |
| Code Lines | 39 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 |
||
| 61 | protected function addModelAdminLinks() |
||
| 62 | { |
||
| 63 | $modelAdmins = []; |
||
| 64 | foreach (ClassInfo::subclassesFor(ModelAdmin::class, false) as $className) { |
||
| 65 | if($className === ArchiveAdmin::class) { |
||
| 66 | continue; |
||
| 67 | } |
||
| 68 | $modelAdmins[$className] = $className; |
||
| 69 | |||
| 70 | } |
||
| 71 | foreach($modelAdmins as $modelAdminClassName) { |
||
| 72 | $groupAdded = false; |
||
| 73 | $ma = Injector::inst()->get($modelAdminClassName); |
||
| 74 | $mas = $ma->getManagedModels(); |
||
| 75 | if(count($mas)) { |
||
| 76 | $numberOfModels = count($mas); |
||
| 77 | $groupCode = strtoupper($modelAdminClassName); |
||
| 78 | $count = 0; |
||
| 79 | foreach($mas as $model => $title) { |
||
| 80 | $count++; |
||
| 81 | if($count > 7) { |
||
| 82 | break; |
||
| 83 | } |
||
| 84 | if(is_array($title)) { |
||
| 85 | $title = $title['title']; |
||
| 86 | $model = $title['dataClass'] ?? $model; |
||
| 87 | } |
||
| 88 | if(! class_exists($model)) { |
||
| 89 | continue; |
||
| 90 | } |
||
| 91 | if(! $groupAdded) { |
||
| 92 | $this->addGroup($groupCode, $ma->menu_title(), 100); |
||
| 93 | $groupAdded = true; |
||
| 94 | } |
||
| 95 | $obj = DataObject::singleton($model); |
||
| 96 | $link = ''; |
||
| 97 | if($obj->hasMethod('CMSListLink')) { |
||
| 98 | $link = $obj->CMSListLink(); |
||
| 99 | } else { |
||
| 100 | $link = $ma->getLinkForModelTab($model); |
||
| 101 | } |
||
| 102 | $this->addLink($groupCode, '✎ '.$title, $link); |
||
| 103 | if($numberOfModels < 4) { |
||
| 104 | $obj = Injector::inst()->get($model); |
||
| 105 | if($obj->canCreate()) { |
||
| 106 | $classNameEscaped = str_replace('\\', '-', $model); |
||
| 107 | $linkNew = $link .= '/EditForm/field/'.$classNameEscaped.'/item/new'; |
||
| 108 | $this->addLink($groupCode, '+ New '.$obj->i18n_singular_name(), $linkNew); |
||
| 109 | } |
||
| 110 | } |
||
| 111 | } |
||
| 112 | } else { |
||
| 113 | |||
| 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