Conditions | 5 |
Paths | 4 |
Total Lines | 72 |
Code Lines | 54 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 30 |
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 |
||
106 | public function store(Request $request) { |
||
107 | |||
108 | $input = $request->input(); |
||
109 | |||
110 | $job = new JobPoster(); |
||
111 | $job->manager_id = $request->user()->manager->id; |
||
112 | $job->published = ($input['submit'] == 'publish'); |
||
113 | $job->fill([ |
||
114 | 'job_term_id' => JobTerm::where('name', 'month')->firstOrFail()->id, |
||
115 | 'term_qty' => $input['term_qty'], |
||
116 | 'open_date_time' => new Date($input['open_date_time']), |
||
117 | 'close_date_time' => new Date($input['close_date_time']), |
||
118 | 'start_date_time' => new Date($input['start_date_time']), |
||
119 | 'department_id' => $input['department'], |
||
120 | 'province_id' => $input['province'], |
||
121 | 'salary_min' => $input['salary_min'], |
||
122 | 'salary_max' => $input['salary_max'], |
||
123 | 'noc' => $input['noc'], |
||
124 | 'classification' => $input['classification'], |
||
125 | 'security_clearance_id' => $input['security_clearance'], |
||
126 | 'language_requirement_id' => $input['language_requirement'], |
||
127 | 'en' => [ |
||
128 | 'city' => $input['city'], |
||
129 | 'title' => $input['title']['en'], |
||
130 | 'impact' => $input['impact']['en'], |
||
131 | 'branch' => $input['branch']['en'], |
||
132 | 'division' => $input['division']['en'] |
||
133 | ], |
||
134 | 'fr' => [ |
||
135 | 'city' => $input['city'], |
||
136 | 'title' => $input['title']['fr'], |
||
137 | 'impact' => $input['impact']['fr'], |
||
138 | 'branch' => $input['branch']['fr'], |
||
139 | 'division' => $input['division']['fr'] |
||
140 | ], |
||
141 | ]); |
||
142 | $job->save(); |
||
143 | |||
144 | if (isset($input['task'])) { |
||
145 | foreach($input['task'] as $task) { |
||
146 | $jobPosterTask = new JobPosterKeyTask(); |
||
147 | $jobPosterTask->job_poster_id = $job->id; |
||
148 | $jobPosterTask->fill([ |
||
149 | 'en' => [ |
||
150 | 'description' => $task['en'] |
||
151 | ], |
||
152 | 'fr' => [ |
||
153 | 'description' => $task['fr'] |
||
154 | ] |
||
155 | ]); |
||
156 | $jobPosterTask->save(); |
||
157 | } |
||
158 | } |
||
159 | |||
160 | if (isset($input['question'])) { |
||
161 | foreach($input['question'] as $question) { |
||
162 | $jobQuestion = new JobPosterQuestion(); |
||
163 | $jobQuestion->job_poster_id = $job->id; |
||
164 | $jobQuestion->fill([ |
||
165 | 'en'=> [ |
||
166 | 'question' => $question['question']['en'], |
||
167 | 'description' => $question['description']['en'] |
||
168 | ], |
||
169 | 'fr'=> [ |
||
170 | 'question' => $question['question']['fr'], |
||
171 | 'description' => $question['description']['fr'] |
||
172 | ] |
||
173 | ]); |
||
174 | $jobQuestion->save(); |
||
175 | } |
||
176 | } |
||
177 | return redirect( route('manager.jobs.index') ); |
||
1 ignored issue
–
show
|
|||
178 | } |
||
180 |