| Conditions | 20 |
| Paths | 65 |
| Total Lines | 56 |
| Code Lines | 36 |
| 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 |
||
| 76 | public function updateSearchContentFromElementalsExtractData($object): string |
||
| 77 | { |
||
| 78 | $owner = $this->getOwner(); |
||
| 79 | $badTypes = $owner->getUnsearchableTypes(); |
||
| 80 | $unsetFields = $owner->getUnsearchableFields(); |
||
| 81 | $string = ''; |
||
| 82 | foreach (['db', 'has_one', 'belongs', 'has_many', 'many_many', 'belongs_many_many'] as $relType) { |
||
| 83 | $fields = Config::inst()->get($object->ClassName, $relType); |
||
| 84 | if (! empty($fields)) { |
||
| 85 | foreach ($fields as $name => $type) { |
||
| 86 | if (! in_array($type, $badTypes, true) && ! in_array($name, $unsetFields, true)) { |
||
| 87 | if (0 === stripos($type, 'Enum')) { |
||
| 88 | continue; |
||
| 89 | } |
||
| 90 | |||
| 91 | $endValue = ''; |
||
| 92 | switch ($relType) { |
||
| 93 | case 'db': |
||
| 94 | $endValue = $object->{$name}; |
||
| 95 | $isList = false; |
||
| 96 | |||
| 97 | break; |
||
| 98 | case 'belongs': |
||
| 99 | case 'has_one': |
||
| 100 | $values = $object->{$name}(); |
||
| 101 | $endValue = $values && $values->exists() ? $values->getTitle() : ''; |
||
| 102 | $isList = false; |
||
| 103 | |||
| 104 | break; |
||
| 105 | default: |
||
| 106 | $isList = true; |
||
| 107 | } |
||
| 108 | |||
| 109 | if ($isList) { |
||
| 110 | $listValues = []; |
||
| 111 | $values = $object->{$name}(); |
||
| 112 | if ($values && $values->exists() && $values->count() < 13) { |
||
| 113 | foreach ($values as $item) { |
||
| 114 | if ($item && $item->exists()) { |
||
| 115 | $listValues[] = $item->getTitle(); |
||
| 116 | } |
||
| 117 | } |
||
| 118 | } |
||
| 119 | |||
| 120 | $endValue = implode('; ', array_filter($listValues)); |
||
| 121 | } |
||
| 122 | |||
| 123 | $data = trim(strip_tags((string) $endValue)); |
||
| 124 | // $string .= $data ? $name . ': '.$data . '; ' : $name.' missing; '; |
||
| 125 | $string .= $data ? $data . '; ' : ''; |
||
| 126 | } |
||
| 127 | } |
||
| 128 | } |
||
| 129 | } |
||
| 130 | |||
| 131 | return $string; |
||
| 132 | } |
||
| 168 |
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