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