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 |
||
81 | public function show(JobApplication $application) |
||
82 | { |
||
83 | $response_poster = false; |
||
84 | $show_review = true; |
||
85 | $jobPoster = $application->job_poster; |
||
86 | |||
87 | if ($jobPoster->isInStrategicResponseDepartment()) { |
||
88 | $response_poster = true; |
||
89 | $show_review = false; |
||
90 | } |
||
91 | |||
92 | $essential_criteria = $jobPoster->criteria->filter(function ($value, $key) { |
||
93 | return $value->criteria_type->name == 'essential' |
||
94 | && $value->skill->skill_type->name == 'hard'; |
||
95 | }); |
||
96 | $asset_criteria = $jobPoster->criteria->filter(function ($value, $key) { |
||
97 | return $value->criteria_type->name == 'asset' |
||
98 | && $value->skill->skill_type->name == 'hard'; |
||
99 | }); |
||
100 | |||
101 | // Display slightly different views on different portals. |
||
102 | $view = WhichPortal::isManagerPortal() || WhichPortal::isHrPortal() ? |
||
103 | 'manager/application_post' : 'applicant/application_preview'; |
||
104 | |||
105 | $application_view = $response_poster |
||
106 | ? 'applicant/strategic_response_application/application_view/application_layout' |
||
107 | : 'common/application/view/view_layout'; |
||
108 | |||
109 | if (WhichPortal::isManagerPortal() || WhichPortal::isHrPortal()) { |
||
110 | // Load things required for review component. |
||
111 | $application->load(['veteran_status', 'citizenship_declaration', 'application_review', 'applicant.user']); |
||
112 | } |
||
113 | |||
114 | |||
115 | // If the application status is draft then get data through the applicant model. |
||
116 | // Else, grab the data from the application itself. |
||
117 | if ($application->isDraft()) { |
||
118 | $source = $application->applicant; |
||
119 | $show_review = false; |
||
120 | } else { |
||
121 | $source = $application; |
||
122 | } |
||
123 | |||
124 | $degrees = $source->degrees; |
||
125 | $courses = $source->courses; |
||
126 | $work_experiences = $source->work_experiences; |
||
127 | $skill_declarations = $source->skill_declarations; |
||
128 | $references = $source->references; |
||
129 | $work_samples = $source->work_samples; |
||
130 | |||
131 | $custom_breadcrumbs = [ |
||
132 | 'home' => route('home'), |
||
133 | 'applications' => route('applications.index'), |
||
134 | 'application' => '', |
||
135 | ]; |
||
136 | |||
137 | if (WhichPortal::isManagerPortal() || WhichPortal::isHrPortal()) { |
||
138 | $custom_breadcrumbs = [ |
||
139 | 'home' => route('home'), |
||
140 | 'jobs' => route(WhichPortal::prefixRoute('jobs.index')), |
||
141 | $jobPoster->title => route(WhichPortal::prefixRoute('jobs.summary'), $jobPoster), |
||
142 | 'applications' => route(WhichPortal::prefixRoute('jobs.applications'), $jobPoster), |
||
143 | 'application' => '', |
||
144 | ]; |
||
145 | } |
||
146 | |||
147 | return view( |
||
148 | $view, |
||
149 | [ |
||
150 | 'application_view_template' => $application_view, |
||
151 | // Localized strings. |
||
152 | 'post' => Lang::get('manager/application_post'), // Change text |
||
153 | 'is_manager_view' => WhichPortal::isManagerPortal(), |
||
154 | 'is_hr_portal' => WhichPortal::isHrPortal(), |
||
155 | // Application Template Data. |
||
156 | 'application_template' => Lang::get('applicant/application_template'), |
||
157 | 'citizenship_declaration_template' => Lang::get('common/citizenship_declaration'), |
||
158 | 'veteran_status_template' => Lang::get('common/veteran_status'), |
||
159 | // Job Data. |
||
160 | 'job' => $jobPoster, |
||
161 | // Skills Data. |
||
162 | 'skills' => Skill::all(), |
||
163 | 'skill_template' => Lang::get('common/skills'), |
||
164 | 'reference_template' => Lang::get('common/references'), |
||
165 | 'sample_template' => Lang::get('common/work_samples'), |
||
166 | 'essential_criteria' => $essential_criteria, |
||
167 | 'asset_criteria' => $asset_criteria, |
||
168 | // Applicant Data. |
||
169 | 'applicant' => $application->applicant, |
||
170 | 'job_application' => $application, |
||
171 | 'degrees' => $degrees, |
||
172 | 'courses' => $courses, |
||
173 | 'work_experiences' => $work_experiences, |
||
174 | 'skill_declarations' => $skill_declarations, |
||
175 | 'references' => $references, |
||
176 | 'work_samples' => $work_samples, |
||
177 | 'review_statuses' => ReviewStatus::all(), |
||
178 | 'custom_breadcrumbs' => $custom_breadcrumbs, |
||
179 | 'response_poster' => $response_poster, |
||
180 | 'show_review' => $show_review, |
||
181 | ] |
||
207 |