| Conditions | 9 |
| Paths | 8 |
| Total Lines | 93 |
| Code Lines | 66 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 90 |
| 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 |
||
| 117 | public function store(Request $request) { |
||
| 118 | |||
| 119 | $input = $request->input(); |
||
| 120 | |||
| 121 | $job = new JobPoster(); |
||
| 122 | $job->manager_id = $request->user()->manager->id; |
||
| 123 | $job->published = ($input['submit'] == 'publish'); |
||
| 124 | $job->fill([ |
||
| 125 | 'job_term_id' => JobTerm::where('name', 'month')->firstOrFail()->id, |
||
| 126 | 'term_qty' => $input['term_qty'], |
||
| 127 | 'open_date_time' => new Date($input['open_date_time']), |
||
| 128 | 'close_date_time' => new Date($input['close_date_time']), |
||
| 129 | 'start_date_time' => new Date($input['start_date_time']), |
||
| 130 | 'department_id' => $input['department'], |
||
| 131 | 'province_id' => $input['province'], |
||
| 132 | 'salary_min' => $input['salary_min'], |
||
| 133 | 'salary_max' => $input['salary_max'], |
||
| 134 | 'noc' => $input['noc'], |
||
| 135 | 'classification' => $input['classification'], |
||
| 136 | 'security_clearance_id' => $input['security_clearance'], |
||
| 137 | 'language_requirement_id' => $input['language_requirement'], |
||
| 138 | 'en' => [ |
||
| 139 | 'city' => $input['city'], |
||
| 140 | 'title' => $input['title']['en'], |
||
| 141 | 'impact' => $input['impact']['en'], |
||
| 142 | 'branch' => $input['branch']['en'], |
||
| 143 | 'division' => $input['division']['en'] |
||
| 144 | ], |
||
| 145 | 'fr' => [ |
||
| 146 | 'city' => $input['city'], |
||
| 147 | 'title' => $input['title']['fr'], |
||
| 148 | 'impact' => $input['impact']['fr'], |
||
| 149 | 'branch' => $input['branch']['fr'], |
||
| 150 | 'division' => $input['division']['fr'] |
||
| 151 | ], |
||
| 152 | ]); |
||
| 153 | $job->save(); |
||
| 154 | |||
| 155 | if (isset($input['task'])) { |
||
| 156 | foreach($input['task'] as $task) { |
||
| 157 | $jobPosterTask = new JobPosterKeyTask(); |
||
| 158 | $jobPosterTask->job_poster_id = $job->id; |
||
| 159 | $jobPosterTask->fill([ |
||
| 160 | 'en' => [ |
||
| 161 | 'description' => $task['en'] |
||
| 162 | ], |
||
| 163 | 'fr' => [ |
||
| 164 | 'description' => $task['fr'] |
||
| 165 | ] |
||
| 166 | ]); |
||
| 167 | $jobPosterTask->save(); |
||
| 168 | } |
||
| 169 | } |
||
| 170 | |||
| 171 | if (isset($input['question'])) { |
||
| 172 | foreach($input['question'] as $question) { |
||
| 173 | $jobQuestion = new JobPosterQuestion(); |
||
| 174 | $jobQuestion->job_poster_id = $job->id; |
||
| 175 | $jobQuestion->fill([ |
||
| 176 | 'en'=> [ |
||
| 177 | 'question' => $question['question']['en'], |
||
| 178 | 'description' => $question['description']['en'] |
||
| 179 | ], |
||
| 180 | 'fr'=> [ |
||
| 181 | 'question' => $question['question']['fr'], |
||
| 182 | 'description' => $question['description']['fr'] |
||
| 183 | ] |
||
| 184 | ]); |
||
| 185 | $jobQuestion->save(); |
||
| 186 | } |
||
| 187 | } |
||
| 188 | |||
| 189 | $criteria = $input['criteria']; |
||
| 190 | |||
| 191 | //Save new criteria |
||
| 192 | if (isset($criteria['new'])) { |
||
| 193 | foreach($criteria['new'] as $criteriaType => $criteriaTypeInput) { |
||
| 194 | foreach($criteriaTypeInput as $skillType => $skillTypeInput) { |
||
| 195 | foreach($skillTypeInput as $criteriaInput) { |
||
| 196 | $criteria = new Criteria(); |
||
| 197 | $criteria->job_poster_id = $job->id; |
||
| 198 | $criteria->fill([ |
||
| 199 | 'criteria_type_id' => CriteriaType::where('name', $criteriaType)->firstOrFail()->id, |
||
| 200 | 'skill_id' => $criteriaInput['skill_id'], |
||
| 201 | 'skill_level_id' => $criteriaInput['skill_level_id'], |
||
| 202 | ]); |
||
| 203 | $criteria->save(); |
||
| 204 | } |
||
| 205 | } |
||
| 206 | } |
||
| 207 | } |
||
| 208 | |||
| 209 | return redirect( route('manager.jobs.index') ); |
||
|
1 ignored issue
–
show
|
|||
| 210 | } |
||
| 212 |