We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Conditions | 23 |
Paths | 576 |
Total Lines | 60 |
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 |
||
20 | public function compactFakeFields($requestInput, $model = false, $fields = []) |
||
21 | { |
||
22 | // get the right fields according to the form type (create/update) |
||
23 | if (empty($fields)) { |
||
24 | $fields = $this->fields(); |
||
25 | } |
||
26 | |||
27 | $model = $model ? (is_string($model) ? app($model) : $model) : $this->model; |
||
28 | |||
29 | $compactedFakeFields = []; |
||
30 | |||
31 | foreach ($fields as $field) { |
||
32 | // compact fake fields |
||
33 | // explode the comma delimited names, eg: start,end in a date_range: |
||
34 | $field['name'] = explode(',', $field['name']); |
||
35 | foreach ($field['name'] as $fieldName) { |
||
36 | $fakeFieldKey = isset($field['store_in']) ? $field['store_in'] : 'extras'; |
||
37 | $isFakeField = $field['fake'] ?? false; |
||
38 | |||
39 | // field is represented by the subfields |
||
40 | if (isset($field['subfields']) && isset($field['model']) && $field['model'] === get_class($model)) { |
||
41 | foreach ($field['subfields'] as $subfield) { |
||
42 | // explode the comma delimited names, eg: start,end in a date_range: |
||
43 | $subfield['name'] = explode(',', $subfield['name']); |
||
44 | foreach ($subfield['name'] as $subfieldName) { |
||
45 | $subfieldName = Str::afterLast($subfieldName, '.'); |
||
46 | $isSubfieldFake = $subfield['fake'] ?? false; |
||
47 | $subFakeFieldKey = isset($subfield['store_in']) ? $subfield['store_in'] : 'extras'; |
||
48 | |||
49 | if (array_key_exists($subfieldName, $requestInput) && $isSubfieldFake) { |
||
50 | $this->addCompactedField($requestInput, $subfieldName, $subFakeFieldKey); |
||
51 | |||
52 | if (! in_array($subFakeFieldKey, $compactedFakeFields)) { |
||
53 | $compactedFakeFields[] = $subFakeFieldKey; |
||
54 | } |
||
55 | } |
||
56 | } |
||
57 | } |
||
58 | continue; |
||
59 | } |
||
60 | |||
61 | if (array_key_exists($fieldName, $requestInput) && $isFakeField) { |
||
62 | $this->addCompactedField($requestInput, $fieldName, $fakeFieldKey); |
||
63 | |||
64 | if (! in_array($fakeFieldKey, $compactedFakeFields)) { |
||
65 | $compactedFakeFields[] = $fakeFieldKey; |
||
66 | } |
||
67 | } |
||
68 | } |
||
69 | } |
||
70 | |||
71 | // json_encode all fake_value columns if applicable in the database, so they can be properly stored and interpreted |
||
72 | foreach ($compactedFakeFields as $value) { |
||
73 | if (! (property_exists($model, 'translatable') && in_array($value, $model->getTranslatableAttributes(), true)) && $model->shouldEncodeFake($value)) { |
||
74 | $requestInput[$value] = json_encode($requestInput[$value]); |
||
75 | } |
||
76 | } |
||
77 | |||
78 | // if there are no fake fields defined, return the original request input |
||
79 | return $requestInput; |
||
80 | } |
||
97 |
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