| Conditions | 15 |
| Paths | 16 |
| Total Lines | 46 |
| Code Lines | 29 |
| 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 |
||
| 101 | protected function detectField($column) |
||
| 102 | { |
||
| 103 | if ($column === $this->model->getKeyName()) { |
||
| 104 | return Id::class; |
||
| 105 | } |
||
| 106 | |||
| 107 | $data = $this->fetchTablesColumns()[$column]; |
||
| 108 | $className = class_basename($data->getType()); |
||
| 109 | |||
| 110 | switch (true) { |
||
| 111 | case $this->model instanceof Rankable && $column === $this->model->getRankableColumn(): |
||
| 112 | return Rank::class; |
||
| 113 | case in_array($className, ['TimeType', 'DateType', 'DateTimeType'], true): |
||
| 114 | $type = str_replace('Type', '', $className); |
||
| 115 | |||
| 116 | return "\\Terranet\\Administrator\\Field\\{$type}"; |
||
| 117 | case 'BooleanType' === $className: |
||
| 118 | return Boolean::class; |
||
| 119 | case 'TextType' === $className: |
||
| 120 | return Textarea::class; |
||
| 121 | case 'StringType' === $className: |
||
| 122 | if (connection('mysql') && !$data->getLength()) { |
||
| 123 | if ($values = enum_values($this->model->getTable(), $column)) { |
||
| 124 | $values = translated_values($values, app('scaffold.module')->url(), $column); |
||
| 125 | if (!$data->getNotNull()) { |
||
| 126 | $values = ['' => '----'] + $values; |
||
| 127 | } |
||
| 128 | |||
| 129 | return Enum::make($column, $column)->setOptions($values); |
||
| 130 | } |
||
| 131 | } |
||
| 132 | |||
| 133 | if (str_contains($column, 'email')) { |
||
| 134 | return Email::class; |
||
| 135 | } |
||
| 136 | |||
| 137 | if (str_contains($column, ['url', 'site', 'host'])) { |
||
| 138 | return Link::class; |
||
| 139 | } |
||
| 140 | |||
| 141 | if (str_contains($column, ['phone', 'gsm'])) { |
||
| 142 | return Phone::class; |
||
| 143 | } |
||
| 144 | // no break |
||
| 145 | default: |
||
| 146 | return Text::class; |
||
| 147 | } |
||
| 158 |
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