| Conditions | 5 | 
| Paths | 5 | 
| Total Lines | 80 | 
| Code Lines | 56 | 
| 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  | 
            ||
| 17 | static function generateFormConfig($table, $coloms)  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 18 |     { | 
            ||
| 19 | $formArrayString = [];  | 
            ||
| 20 |         foreach ($coloms as $i => $colName) { | 
            ||
| 21 | //$attribute = [];  | 
            ||
| 22 | $input = [  | 
            ||
| 23 | 'label' => self::getLabel($colName),  | 
            ||
| 24 | 'name' => $colName,  | 
            ||
| 25 | 'type' => '',  | 
            ||
| 26 | 'options' => '',  | 
            ||
| 27 | 'required' => true,  | 
            ||
| 28 | 'validation' => '',  | 
            ||
| 29 | 'help' => '',  | 
            ||
| 30 | 'placeholder' => '',  | 
            ||
| 31 | ];  | 
            ||
| 32 | |||
| 33 |             if (FieldDetector::isExceptional($colName)) { | 
            ||
| 34 | continue;  | 
            ||
| 35 | }  | 
            ||
| 36 | |||
| 37 | $typeData = DbInspector::getFieldTypes($table, $colName);  | 
            ||
| 38 | |||
| 39 | list($input['type'], $input['validation'], $input['options']) = self::parseFieldType($typeData);  | 
            ||
| 40 | |||
| 41 |             if (FieldDetector::isForeignKey($colName)) { | 
            ||
| 42 | list($input['type'], $input['options']) = self::handleForeignKey($colName);  | 
            ||
| 43 |             } elseif (substr($colName, 0, 3) == 'is_') { | 
            ||
| 44 | $input['type'] = 'radio_dataenum';  | 
            ||
| 45 | $label = ucwords(substr($colName, 3));  | 
            ||
| 46 | $input['options'] = [  | 
            ||
| 47 | 'enum' => ['In '.$label, $label],  | 
            ||
| 48 | 'value' => [0, 1],  | 
            ||
| 49 | ];  | 
            ||
| 50 | }  | 
            ||
| 51 | |||
| 52 | $map = [  | 
            ||
| 53 | 'password' => [  | 
            ||
| 54 | 'type' => 'password',  | 
            ||
| 55 | 'validation' => 'min:5|max:32|required',  | 
            ||
| 56 |                     'help' => cbTrans("text_default_help_password"), | 
            ||
| 57 | ],  | 
            ||
| 58 | 'image' => [  | 
            ||
| 59 | 'type' => 'upload',  | 
            ||
| 60 | 'validation' => 'required|image',  | 
            ||
| 61 |                     'help' => cbTrans('text_default_help_upload'), | 
            ||
| 62 | ],  | 
            ||
| 63 | 'geo' => [  | 
            ||
| 64 | 'type' => 'hidden',  | 
            ||
| 65 | 'validation' => 'required|numeric',  | 
            ||
| 66 | ],  | 
            ||
| 67 | 'phone' => [  | 
            ||
| 68 | 'type' => 'number',  | 
            ||
| 69 | 'validation' => 'required|numeric',  | 
            ||
| 70 |                     'placeholder' => cbTrans('text_default_help_number'), | 
            ||
| 71 | ],  | 
            ||
| 72 | 'email' => [  | 
            ||
| 73 | 'type' => 'email',  | 
            ||
| 74 | 'validation' => 'require|email|unique:'.$table,  | 
            ||
| 75 |                     'placeholder' => cbTrans('text_default_help_email'), | 
            ||
| 76 | ],  | 
            ||
| 77 | 'name' => [  | 
            ||
| 78 | 'type' => 'text',  | 
            ||
| 79 | 'validation' => 'required|string|min:3|max:70',  | 
            ||
| 80 |                     'placeholder' => cbTrans('text_default_help_text'), | 
            ||
| 81 | ],  | 
            ||
| 82 | 'url' => [  | 
            ||
| 83 | 'type' => 'text',  | 
            ||
| 84 | 'validation' => 'required|url',  | 
            ||
| 85 |                     'placeholder' => cbTrans('text_default_help_url'), | 
            ||
| 86 | ],  | 
            ||
| 87 | ];  | 
            ||
| 88 | |||
| 89 | $props = array_get($map, FieldDetector::detect($colName));  | 
            ||
| 90 | unset($map);  | 
            ||
| 91 | $input = array_merge($input, $props);  | 
            ||
| 92 | |||
| 93 |             $formArrayString[] = FileManipulator::stringify($input, str_repeat(" ", 12)); | 
            ||
| 94 | }  | 
            ||
| 95 | |||
| 96 | return $formArrayString;  | 
            ||
| 97 | }  | 
            ||
| 155 | }  | 
            
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.