Conditions | 12 |
Paths | 128 |
Total Lines | 100 |
Code Lines | 69 |
Lines | 0 |
Ratio | 0 % |
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 |
||
56 | public function show(JobApplication $application) |
||
57 | { |
||
58 | $response_poster = false; |
||
59 | $show_review = true; |
||
60 | $jobPoster = $application->job_poster; |
||
61 | |||
62 | if ($jobPoster->isInStrategicResponseDepartment()) { |
||
63 | $response_poster = true; |
||
64 | $show_review = false; |
||
65 | } |
||
66 | |||
67 | $essential_criteria = $jobPoster->criteria->filter(function ($value, $key) { |
||
68 | return $value->criteria_type->name == 'essential' |
||
69 | && $value->skill->skill_type->name == 'hard'; |
||
70 | }); |
||
71 | $asset_criteria = $jobPoster->criteria->filter(function ($value, $key) { |
||
72 | return $value->criteria_type->name == 'asset' |
||
73 | && $value->skill->skill_type->name == 'hard'; |
||
74 | }); |
||
75 | |||
76 | // Display slightly different views on different portals. |
||
77 | $view = WhichPortal::isManagerPortal() || WhichPortal::isHrPortal() ? |
||
78 | 'manager/application_post' : 'applicant/application_preview'; |
||
79 | |||
80 | $application_view = $response_poster |
||
81 | ? 'applicant/strategic_response_application/application_view/application_layout' |
||
82 | : 'common/application/view/view_layout'; |
||
83 | |||
84 | if (WhichPortal::isManagerPortal() || WhichPortal::isHrPortal()) { |
||
85 | // Load things required for review component. |
||
86 | $application->load(['veteran_status', 'citizenship_declaration', 'application_review', 'applicant.user']); |
||
87 | } |
||
88 | |||
89 | |||
90 | // If the application status is draft then get data through the applicant model. |
||
91 | // Else, grab the data from the application itself. |
||
92 | if ($application->isDraft()) { |
||
93 | $source = $application->applicant; |
||
94 | $show_review = false; |
||
95 | } else { |
||
96 | $source = $application; |
||
97 | } |
||
98 | |||
99 | $degrees = $source->degrees; |
||
100 | $courses = $source->courses; |
||
101 | $work_experiences = $source->work_experiences; |
||
102 | $skill_declarations = $source->skill_declarations; |
||
103 | $references = $source->references; |
||
104 | $work_samples = $source->work_samples; |
||
105 | |||
106 | $custom_breadcrumbs = [ |
||
107 | 'home' => route('home'), |
||
108 | 'applications' => route('applications.index'), |
||
109 | 'application' => '', |
||
110 | ]; |
||
111 | |||
112 | if (WhichPortal::isManagerPortal() || WhichPortal::isHrPortal()) { |
||
113 | $custom_breadcrumbs = [ |
||
114 | 'home' => route('home'), |
||
115 | 'jobs' => route(WhichPortal::prefixRoute('jobs.index')), |
||
116 | $jobPoster->title => route(WhichPortal::prefixRoute('jobs.summary'), $jobPoster), |
||
117 | 'applications' => route(WhichPortal::prefixRoute('jobs.applications'), $jobPoster), |
||
118 | 'application' => '', |
||
119 | ]; |
||
120 | } |
||
121 | |||
122 | return view( |
||
123 | $view, |
||
124 | [ |
||
125 | 'application_view_template' => $application_view, |
||
126 | // Localized strings. |
||
127 | 'post' => Lang::get('manager/application_post'), // Change text |
||
128 | 'is_manager_view' => WhichPortal::isManagerPortal(), |
||
129 | 'is_hr_portal' => WhichPortal::isHrPortal(), |
||
130 | // Application Template Data. |
||
131 | 'application_template' => Lang::get('applicant/application_template'), |
||
132 | 'citizenship_declaration_template' => Lang::get('common/citizenship_declaration'), |
||
133 | 'veteran_status_template' => Lang::get('common/veteran_status'), |
||
134 | // Job Data. |
||
135 | 'job' => $jobPoster, |
||
136 | // Skills Data. |
||
137 | 'skills' => Skill::all(), |
||
138 | 'skill_template' => Lang::get('common/skills'), |
||
139 | 'reference_template' => Lang::get('common/references'), |
||
140 | 'sample_template' => Lang::get('common/work_samples'), |
||
141 | 'essential_criteria' => $essential_criteria, |
||
142 | 'asset_criteria' => $asset_criteria, |
||
143 | // Applicant Data. |
||
144 | 'applicant' => $application->applicant, |
||
145 | 'job_application' => $application, |
||
146 | 'degrees' => $degrees, |
||
147 | 'courses' => $courses, |
||
148 | 'work_experiences' => $work_experiences, |
||
149 | 'skill_declarations' => $skill_declarations, |
||
150 | 'references' => $references, |
||
151 | 'work_samples' => $work_samples, |
||
152 | 'review_statuses' => ReviewStatus::all(), |
||
153 | 'custom_breadcrumbs' => $custom_breadcrumbs, |
||
154 | 'response_poster' => $response_poster, |
||
155 | 'show_review' => $show_review, |
||
156 | ] |
||
182 |