| Conditions | 9 |
| Paths | 28 |
| Total Lines | 96 |
| Code Lines | 68 |
| 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 | $job_review_data = [ |
||
| 33 | 'imgSrc' => '/images/job-process-summary-tool-edit.svg', |
||
| 34 | 'imgAlt' => "{$summaryLang['edit_poster_icon']} {$summaryLang['flat_icons']}", |
||
| 35 | 'text' => $summaryLang['edit_poster_button'], |
||
| 36 | 'url' => route('hr_advisor.jobs.review', $job), |
||
|
|
|||
| 37 | 'disabled' => false, |
||
| 38 | ]; |
||
| 39 | |||
| 40 | $job_preview_data = [ |
||
| 41 | 'imgSrc' => '/images/job-process-summary-tool-view.svg', |
||
| 42 | 'imgAlt' => "{$summaryLang['view_poster_icon']} {$summaryLang['flat_icons']}", |
||
| 43 | 'text' => $summaryLang['view_poster_button'], |
||
| 44 | 'url' => route('hr_advisor.jobs.preview', $job), |
||
| 45 | 'disabled' => false, |
||
| 46 | ]; |
||
| 47 | |||
| 48 | $screening_plan_data = [ |
||
| 49 | 'imgSrc' => '/images/job-process-summary-tool-screen.svg', |
||
| 50 | 'imgAlt' => "{$summaryLang['screening_plan_icon']} {$summaryLang['flat_icons']}", |
||
| 51 | 'text' => $summaryLang['screening_plan_button'], |
||
| 52 | 'url' => '/', |
||
| 53 | 'disabled' => true, // TODO: Update when screening plan for HR is ready |
||
| 54 | ]; |
||
| 55 | |||
| 56 | $view_applicants_data = [ |
||
| 57 | 'imgSrc' => '/images/job-process-summary-tool-applicants.svg', |
||
| 58 | 'imgAlt' => "{$summaryLang['view_applicants_icon']} {$summaryLang['flat_icons']}", |
||
| 59 | 'text' => $summaryLang['view_applicants_button'], |
||
| 60 | 'url' => route('hr_advisor.jobs.applications', $job), |
||
| 61 | 'disabled' => !$job->isClosed(), |
||
| 62 | ]; |
||
| 63 | |||
| 64 | |||
| 65 | |||
| 66 | switch ($job->job_status_id) { |
||
| 67 | case 1: |
||
| 68 | $status = Lang::get('common/lookup/job_status.draft'); |
||
| 69 | break; |
||
| 70 | case 2: |
||
| 71 | $status = Lang::get('common/lookup/job_status.in_review'); |
||
| 72 | break; |
||
| 73 | case 3: |
||
| 74 | $status = Lang::get('common/lookup/job_status.approved'); |
||
| 75 | break; |
||
| 76 | case 4: |
||
| 77 | $status = Lang::get('common/lookup/job_status.open'); |
||
| 78 | break; |
||
| 79 | case 5: |
||
| 80 | $status = Lang::get('common/lookup/job_status.closed'); |
||
| 81 | break; |
||
| 82 | case 6: |
||
| 83 | $status = Lang::get('common/lookup/job_status.complete'); |
||
| 84 | break; |
||
| 85 | } |
||
| 86 | // TODO: This should change based on the current status. |
||
| 87 | $status_description = $job->job_status_id == 2 |
||
| 88 | ? $summaryLang['under_review'] |
||
| 89 | : ''; |
||
| 90 | |||
| 91 | $data = [ |
||
| 92 | // Localized strings. |
||
| 93 | 'summary' => $summaryLang, |
||
| 94 | 'job_status' => $status, |
||
| 95 | 'job_status_description' => $status_description, |
||
| 96 | 'is_claimed' => $jobIsClaimed, |
||
| 97 | // User data. |
||
| 98 | 'user' => $user, |
||
| 99 | // Job Poster data. |
||
| 100 | 'job' => $job, |
||
| 101 | // Application data. |
||
| 102 | 'applications' => $applications, |
||
| 103 | // TODO: Add Routes. |
||
| 104 | // 'send_manager' => , |
||
| 105 | // 'send_translation' => , |
||
| 106 | // 'approve_publishing' => , |
||
| 107 | 'job_review_data' => $job_review_data, |
||
| 108 | 'job_preview_data' => $job_preview_data, |
||
| 109 | 'screening_plan_data' => $screening_plan_data, |
||
| 110 | 'view_applicants_data' => $view_applicants_data, |
||
| 111 | 'relinquish_job' => route('hr_advisor.jobs.unclaim', $job), |
||
| 112 | ]; |
||
| 113 | |||
| 114 | return view( |
||
| 115 | 'hr_advisor/job_summary', |
||
| 116 | $data |
||
| 117 | ); |
||
| 135 |