| Conditions | 12 |
| Paths | 41 |
| Total Lines | 42 |
| Code Lines | 25 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| 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 |
||
| 67 | protected function workOutLinksForModel($modelAdminSingleton, string $model, string $modelAdminLink, string $modelAdmin) |
||
| 68 | { |
||
| 69 | $links = []; |
||
| 70 | $sanitizedModel = AllLinks::sanitise_class_name($model); |
||
| 71 | $modelLink = $modelAdminLink . $sanitizedModel . '/'; |
||
| 72 | for ($i = 0; $i < $this->numberOfExamples; ++$i) { |
||
| 73 | $item = $model::get() |
||
| 74 | ->sort(DB::get_conn()->random() . ' ASC') |
||
| 75 | ->First() |
||
| 76 | ; |
||
| 77 | $singleton = $item ?: Injector::inst()->get($model); |
||
| 78 | $exceptionMethod = ''; |
||
| 79 | foreach ($this->Config()->get('model_admin_alternatives') as $test => $method) { |
||
| 80 | if (! $method) { |
||
| 81 | $method = 'do-not-use'; |
||
| 82 | } |
||
| 83 | |||
| 84 | if (false !== strpos($modelAdminLink, $test)) { |
||
| 85 | $exceptionMethod = $method; |
||
| 86 | } |
||
| 87 | } |
||
| 88 | |||
| 89 | if ($exceptionMethod) { |
||
| 90 | if ($item && $item->hasMethod($exceptionMethod)) { |
||
| 91 | $links = array_merge($links, $item->{$exceptionMethod}($modelAdminLink)); |
||
| 92 | } |
||
| 93 | } else { |
||
| 94 | //needs to stay here for exception! |
||
| 95 | $links[] = $modelLink; |
||
| 96 | if ($singleton->canCreate(null)) { |
||
| 97 | $links[] = $modelLink . 'EditForm/field/' . $sanitizedModel . '/item/new/'; |
||
| 98 | } |
||
| 99 | |||
| 100 | if ($item) { |
||
| 101 | if ($item->canEdit()) { |
||
| 102 | $links[] = $modelLink . 'EditForm/field/' . $sanitizedModel . '/item/' . $item->ID . '/edit/'; |
||
| 103 | } |
||
| 104 | } |
||
| 105 | } |
||
| 106 | } |
||
| 107 | |||
| 108 | return $links; |
||
| 109 | } |
||
| 122 |
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