Conditions | 17 |
Paths | 192 |
Total Lines | 114 |
Code Lines | 85 |
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' => route('hr_advisor.jobs.screening_plan', $job), |
||
53 | 'disabled' => false |
||
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_poster_status->name) { |
||
67 | case 'draft': |
||
68 | $status = Lang::get('common/lookup/job_status.draft'); |
||
69 | break; |
||
70 | case 'review_hr': |
||
71 | case 'review_manager': |
||
72 | $status = Lang::get('common/lookup/job_status.in_review'); |
||
73 | break; |
||
74 | case 'translation': |
||
75 | $status = Lang::get('common/lookup/job_status.in_translation'); |
||
76 | break; |
||
77 | case 'final_review_manager': |
||
78 | case 'final_review_hr': |
||
79 | $status = Lang::get('common/lookup/job_status.final_review'); |
||
80 | break; |
||
81 | case 'approved': |
||
82 | $status = Lang::get('common/lookup/job_status.approved'); |
||
83 | break; |
||
84 | case 'published': |
||
85 | if ($job->isOpen()) { |
||
86 | $status = Lang::get('common/lookup/job_status.open'); |
||
87 | } elseif ($job->isClosed()) { |
||
88 | $status = Lang::get('common/lookup/job_status.closed'); |
||
89 | } else { |
||
90 | $status = Lang::get('common/lookup/job_status.published'); |
||
91 | } |
||
92 | break; |
||
93 | case 'completed': |
||
94 | $status = Lang::get('common/lookup/job_status.complete'); |
||
95 | break; |
||
96 | } |
||
97 | // TODO: Need to add more descriptions for different statuses |
||
98 | $status_description = |
||
99 | ( |
||
100 | $job->job_poster_status->name === 'review_hr' |
||
101 | || $job->job_poster_status->name === 'review_manager' |
||
102 | || $job->job_poster_status->name === 'final_review_manager' |
||
103 | || $job->job_poster_status->name === 'final_review_hr' |
||
104 | ) |
||
105 | ? $summaryLang['under_review'] |
||
106 | : ''; |
||
107 | |||
108 | $data = [ |
||
109 | // Localized strings. |
||
110 | 'summary' => $summaryLang, |
||
111 | 'job_status' => $status, |
||
112 | 'job_status_description' => $status_description, |
||
113 | 'is_claimed' => $jobIsClaimed, |
||
114 | // User data. |
||
115 | 'user' => $user, |
||
116 | // Job Poster data. |
||
117 | 'job' => $job, |
||
118 | // Application data. |
||
119 | 'applications' => $applications, |
||
120 | // TODO: Add Routes. |
||
121 | 'send_manager' => '', //route('hr_advisor.jobs.setJobStatus', ['jobPoster'=> $job, 'status' => 'review_manager']), |
||
122 | 'send_translation' => '', //route('hr_advisor.jobs.setJobStatus', ['jobPoster'=> $job, 'status' => 'translation']), |
||
123 | 'approve_publishing' => '', //route('hr_advisor.jobs.setJobStatus', ['jobPoster'=> $job, 'status' => 'approved']), |
||
124 | |||
125 | 'job_review_data' => $job_review_data, |
||
126 | 'job_preview_data' => $job_preview_data, |
||
127 | 'screening_plan_data' => $screening_plan_data, |
||
128 | 'view_applicants_data' => $view_applicants_data, |
||
129 | 'relinquish_job' => route('hr_advisor.jobs.unclaim', $job), |
||
130 | ]; |
||
131 | |||
132 | return view( |
||
133 | 'hr_advisor/job_summary', |
||
134 | $data |
||
135 | ); |
||
153 |