| Conditions | 9 |
| Paths | 28 |
| Total Lines | 70 |
| Code Lines | 50 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 21 | public function show(Request $request, JobPoster $job) |
||
| 22 | { |
||
| 23 | $user = Auth::user(); |
||
| 24 | |||
| 25 | $applications = $job->submitted_applications; |
||
| 26 | $advisor = $user->hr_advisor; |
||
| 27 | $jobIsClaimed = ($advisor !== null) && |
||
| 28 | $advisor->claimed_job_ids->contains($job->id); |
||
| 29 | |||
| 30 | $summaryLang = Lang::get('hr_advisor/job_summary'); |
||
| 31 | |||
| 32 | $view_applicants_data = [ |
||
| 33 | 'imgSrc' => '/images/job-process-summary-tool-applicants.svg', |
||
| 34 | 'imgAlt' => "{$summaryLang['view_applicants_icon']} {$summaryLang['flat_icons']}", |
||
| 35 | 'text' => $summaryLang['view_applicants_button'], |
||
| 36 | 'url' => route('hr_advisor.jobs.applications', $job), |
||
|
|
|||
| 37 | 'disabled' => $job->isClosed(), |
||
| 38 | ]; |
||
| 39 | |||
| 40 | switch ($job->job_status_id) { |
||
| 41 | case 1: |
||
| 42 | $status = Lang::get('common/lookup/job_status.draft'); |
||
| 43 | break; |
||
| 44 | case 2: |
||
| 45 | $status = Lang::get('common/lookup/job_status.in_review'); |
||
| 46 | break; |
||
| 47 | case 3: |
||
| 48 | $status = Lang::get('common/lookup/job_status.approved'); |
||
| 49 | break; |
||
| 50 | case 4: |
||
| 51 | $status = Lang::get('common/lookup/job_status.open'); |
||
| 52 | break; |
||
| 53 | case 5: |
||
| 54 | $status = Lang::get('common/lookup/job_status.closed'); |
||
| 55 | break; |
||
| 56 | case 6: |
||
| 57 | $status = Lang::get('common/lookup/job_status.complete'); |
||
| 58 | break; |
||
| 59 | } |
||
| 60 | // TODO: This should change based on the current status. |
||
| 61 | $status_description = $job->job_status_id == 2 |
||
| 62 | ? $summaryLang['under_review'] |
||
| 63 | : ''; |
||
| 64 | |||
| 65 | $data = [ |
||
| 66 | // Localized strings. |
||
| 67 | 'summary' => $summaryLang, |
||
| 68 | 'job_status' => $status, |
||
| 69 | 'job_status_description' => $status_description, |
||
| 70 | 'is_claimed' => $jobIsClaimed, |
||
| 71 | // User data. |
||
| 72 | 'user' => $user, |
||
| 73 | // Job Poster data. |
||
| 74 | 'job' => $job, |
||
| 75 | // Application data. |
||
| 76 | 'applications' => $applications, |
||
| 77 | // TODO: Add Routes. |
||
| 78 | // 'send_manager' => , |
||
| 79 | // 'send_translation' => , |
||
| 80 | // 'approve_publishing' => , |
||
| 81 | 'job_review_url' => route('hr_advisor.jobs.review', $job), |
||
| 82 | 'job_preview_url' => '/', |
||
| 83 | 'screening_plan_url' => '/', |
||
| 84 | 'view_applicants_data' => $view_applicants_data, |
||
| 85 | 'relinquish_job' => route('hr_advisor.jobs.unclaim', $job), |
||
| 86 | ]; |
||
| 87 | |||
| 88 | return view( |
||
| 89 | 'hr_advisor/job_summary', |
||
| 90 | $data |
||
| 91 | ); |
||
| 109 |