| Conditions | 9 |
| Paths | 27 |
| Total Lines | 51 |
| 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 |
||
| 124 | private function readAndInsert($select_column, $table_columns, $value) |
||
| 125 | { |
||
| 126 | $a = []; |
||
| 127 | foreach ($select_column as $sk => $s) { |
||
| 128 | $colname = $table_columns[$sk]; |
||
| 129 | |||
| 130 | if (! CRUDBooster::isForeignKey($colname) || intval($value->$s)) { |
||
| 131 | $a[$colname] = $value->$s; |
||
| 132 | continue; |
||
| 133 | } |
||
| 134 | |||
| 135 | //Skip if value is empty |
||
| 136 | if ($value->$s == '') { |
||
| 137 | continue; |
||
| 138 | } |
||
| 139 | |||
| 140 | $relation_table = CRUDBooster::getTableForeignKey($colname); |
||
| 141 | $relation_moduls = DB::table('cms_moduls')->where('table_name', $relation_table)->first(); |
||
| 142 | |||
| 143 | $relation_class = __NAMESPACE__.'\\'.$relation_moduls->controller; |
||
| 144 | if (! class_exists($relation_class)) { |
||
| 145 | $relation_class = '\App\Http\Controllers\\'.$relation_moduls->controller; |
||
| 146 | } |
||
| 147 | $relation_class = new $relation_class; |
||
| 148 | $relation_class->genericLoader(); |
||
| 149 | |||
| 150 | $title_field = $relation_class->title_field; |
||
| 151 | |||
| 152 | $relation_insert_data = []; |
||
| 153 | $relation_insert_data[$title_field] = $value->$s; |
||
| 154 | |||
| 155 | if (\Schema::hasColumn($relation_table, 'created_at')) { |
||
| 156 | $relation_insert_data['created_at'] = date('Y-m-d H:i:s'); |
||
| 157 | } |
||
| 158 | |||
| 159 | try { |
||
| 160 | $relation_exists = DB::table($relation_table)->where($title_field, $value->$s)->first(); |
||
| 161 | if ($relation_exists) { |
||
| 162 | $relation_primary_key = $relation_class->primary_key; |
||
| 163 | $relation_id = $relation_exists->$relation_primary_key; |
||
| 164 | } else { |
||
| 165 | $relation_id = DB::table($relation_table)->insertGetId($relation_insert_data); |
||
| 166 | } |
||
| 167 | |||
| 168 | $a[$colname] = $relation_id; |
||
| 169 | } catch (\Exception $e) { |
||
| 170 | exit($e); |
||
| 171 | } |
||
| 172 | } |
||
| 173 | |||
| 174 | return $a; |
||
| 175 | } |
||
| 176 | } |
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