| Conditions | 10 |
| Paths | 2 |
| Total Lines | 46 |
| Code Lines | 32 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| 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 |
||
| 28 | public function create(array $attributes, $productId) |
||
| 29 | { |
||
| 30 | $product = ProductService::find($productId); |
||
| 31 | $remove = $this->repo->getModel()->where('product_id', '=', $productId)->delete(); |
||
| 32 | |||
| 33 | $result = false; |
||
| 34 | if (isset($attributes['rows'])) { |
||
| 35 | foreach ($attributes['rows'] as $row) { |
||
| 36 | $data = array(); |
||
| 37 | |||
| 38 | $check = $this->repo->getModel()->where('extra_field_id', '=', $row['extra_field_id'])->where('product_id', '=', $productId)->first(); |
||
| 39 | $data['shop_id'] = auth('hideyobackend')->user()->selected_shop_id; |
||
| 40 | if (!empty($row['extra_field_default_value_id']) or !empty($row['value'])) { |
||
| 41 | if ($check) { |
||
| 42 | $data['modified_by_user_id'] = auth('hideyobackend')->user()->id; |
||
| 43 | $data['extra_field_id'] = $row['extra_field_id']; |
||
| 44 | $data['product_id'] = $product->id; |
||
| 45 | if (isset($row['extra_field_default_value_id']) and $row['extra_field_default_value_id']) { |
||
| 46 | $data['extra_field_default_value_id'] = $row['extra_field_default_value_id']; |
||
| 47 | } else { |
||
| 48 | $data['extra_field_default_value_id'] = null; |
||
| 49 | } |
||
| 50 | |||
| 51 | $data['value'] = $row['value']; |
||
| 52 | |||
| 53 | $result = $this->repo->getModel()->find($check->id); |
||
| 54 | $result->fill($data); |
||
| 55 | $result->save(); |
||
| 56 | } else { |
||
| 57 | $data['modified_by_user_id'] = auth('hideyobackend')->user()->id; |
||
| 58 | $data['extra_field_id'] = $row['extra_field_id']; |
||
| 59 | $data['product_id'] = $product->id; |
||
| 60 | if (isset($row['extra_field_default_value_id']) and $row['extra_field_default_value_id']) { |
||
| 61 | $data['extra_field_default_value_id'] = $row['extra_field_default_value_id']; |
||
| 62 | } |
||
| 63 | $data['value'] = $row['value']; |
||
| 64 | |||
| 65 | $result = $this->repo->getModel(); |
||
| 66 | $result->fill($data); |
||
| 67 | $result->save(); |
||
| 68 | } |
||
| 69 | } |
||
| 70 | } |
||
| 71 | } |
||
| 72 | |||
| 73 | return $result; |
||
| 74 | } |
||
| 77 | } |
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