Conditions | 5 |
Paths | 6 |
Total Lines | 53 |
Code Lines | 39 |
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 |
||
57 | public function save(Request $request) |
||
58 | { |
||
59 | $form = []; |
||
60 | $form_slug = $request->get('form_slug'); |
||
61 | $fields_slug = $request->get('fields_slug'); |
||
62 | $countFS = count($fields_slug); |
||
63 | for ($i=0; $i < $countFS; $i++) { |
||
64 | $form['fields'][$form_slug . '_' . $fields_slug[$i]]['label'] = $request->get('fields_label')[$i]; |
||
65 | $form['fields'][$form_slug . '_' . $fields_slug[$i]]['type'] = $request->get('fields_type')[$i]; |
||
66 | $form['fields'][$form_slug . '_' . $fields_slug[$i]]['class'] = $request->get('fields_class')[$i]; |
||
67 | $form['fields'][$form_slug . '_' . $fields_slug[$i]]['parentclass'] = $request->get('fields_parentclass')[$i]; |
||
68 | $form['fields'][$form_slug . '_' . $fields_slug[$i]]['placeholder'] = $request->get('fields_placeholder')[$i]; |
||
69 | $form['fields'][$form_slug . '_' . $fields_slug[$i]]['validation'] = $request->get('fields_validation')[$i]; |
||
70 | $form['fields'][$form_slug . '_' . $fields_slug[$i]]['value'] = $request->get('fields_value')[$i]; |
||
71 | $countFAN = count(explode(';',$request->get('fields_attributes_name')[$i])); |
||
72 | for ($k=0; $k < $countFAN; $k++) { |
||
73 | $form['fields'][$form_slug . '_' . $fields_slug[$i]]['attributes'][explode(';',$request->get('fields_attributes_name')[$i])[$k]] = explode(';',$request->get('fields_attributes_value')[$i])[$k]; |
||
74 | } |
||
75 | $form['fields'][$form_slug . '_' . $fields_slug[$i]]['required'] = $request->get('fields_required')[$i]; |
||
76 | } |
||
77 | |||
78 | $form['actions']['store'] = $request->get('action_store'); |
||
79 | if($request->get('action_send') == true) { |
||
80 | $countActions = count($request->get('action_send_slug')); |
||
81 | for ($g=0; $g < $countActions; $g++) { |
||
82 | $form['actions']['send'][$request->get('action_send_slug')[$g]]['to'] = $request->get('action_send_to')[$g]; |
||
83 | $form['actions']['send'][$request->get('action_send_slug')[$g]]['to_name'] = $request->get('action_send_to_name')[$g]; |
||
84 | $form['actions']['send'][$request->get('action_send_slug')[$g]]['from'] = $request->get('action_send_from')[$g]; |
||
85 | $form['actions']['send'][$request->get('action_send_slug')[$g]]['from_name'] = $request->get('action_send_from_name')[$g]; |
||
86 | $form['actions']['send'][$request->get('action_send_slug')[$g]]['subject'] = $request->get('action_send_subject')[$g]; |
||
87 | $form['actions']['send'][$request->get('action_send_slug')[$g]]['body'] = $request->get('action_send_body')[$g]; |
||
88 | $form['actions']['send'][$request->get('action_send_slug')[$g]]['files'] = $request->get('action_send_files')[$g]; |
||
89 | $form['actions']['send'][$request->get('action_send_slug')[$g]]['template'] = $request->get('action_send_template')[$g]; |
||
90 | } |
||
91 | |||
92 | } |
||
93 | $form['actions']['redirect'] = $request->get('action_redirect'); |
||
94 | |||
95 | $form['files'] = $request->get('files_allowed'); |
||
96 | |||
97 | $form['button']['class'] = $request->get('button_class'); |
||
98 | $form['button']['label'] = $request->get('button_label'); |
||
99 | $form['button']['id'] = $request->get('button_id'); |
||
100 | |||
101 | // updateOrCreate the site |
||
102 | Form::updateOrCreate( |
||
103 | ['id' => $request->get('form_id')], |
||
104 | ['title' => $request->get('form_title'), |
||
105 | 'slug' => $request->get('form_slug'), |
||
106 | 'form' => $form] |
||
107 | ); |
||
108 | |||
109 | return redirect()->route('dashboard.forms'); |
||
110 | } |
||
175 |