| Conditions | 10 |
| Paths | 8 |
| Total Lines | 43 |
| Code Lines | 31 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 51 | public function toSearchableArray() |
||
| 52 | { |
||
| 53 | if (!sizeof($this->searchableColumns)) { |
||
| 54 | $result = collect($this); |
||
| 55 | } else { |
||
| 56 | $result = collect([ |
||
| 57 | 'id' => $this['id'], |
||
| 58 | ]); |
||
| 59 | foreach ($this->searchableColumns as $searchableColumn) { |
||
| 60 | $result->put($searchableColumn, collect($this)->get($searchableColumn)); |
||
| 61 | } |
||
| 62 | } |
||
| 63 | if (sizeof($this->searchableInnerColumns)) { |
||
| 64 | foreach ($this->searchableInnerColumns as $searchableInnerColumnKey => $searchableInnerColumnValue) { |
||
| 65 | $searchableInnerColumnKey = explode('-', $searchableInnerColumnKey)[0]; |
||
| 66 | $innerModels = explode('.', $searchableInnerColumnKey); |
||
| 67 | $values = $this; |
||
| 68 | foreach ($innerModels as $innerModel) { |
||
| 69 | $values = $values->{$innerModel}; |
||
| 70 | } |
||
| 71 | $values = collect($values); |
||
| 72 | $result->put($searchableInnerColumnKey . '-' . $searchableInnerColumnValue, |
||
| 73 | collect($values)->get($searchableInnerColumnValue)); |
||
| 74 | } |
||
| 75 | } |
||
| 76 | if (sizeof($this->searchableManyInnerColumns)) { |
||
| 77 | foreach ($this->searchableManyInnerColumns as $searchableInnerColumnKey => $searchableInnerColumnValue) { |
||
| 78 | $searchableInnerColumnKey = explode('-', $searchableInnerColumnKey)[0]; |
||
| 79 | $innerModels = explode('.', $searchableInnerColumnKey); |
||
| 80 | $values = $this; |
||
| 81 | foreach ($innerModels as $innerModel) { |
||
| 82 | $values = $values->{$innerModel}; |
||
| 83 | } |
||
| 84 | $values = collect($values); |
||
| 85 | $counter = 0; |
||
| 86 | foreach ($values as $value) { |
||
| 87 | $result->put($searchableInnerColumnKey . '-' . $searchableInnerColumnValue . '-' . $counter, |
||
| 88 | collect($value)->get($searchableInnerColumnValue)); |
||
| 89 | $counter++; |
||
| 90 | } |
||
| 91 | } |
||
| 92 | } |
||
| 93 | return $result->toArray(); |
||
| 94 | } |
||
| 130 |
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