| Conditions | 10 |
| Paths | 32 |
| Total Lines | 93 |
| Code Lines | 64 |
| 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 |
||
| 106 | public function showVersionOne(JobApplication $application) |
||
| 107 | { |
||
| 108 | $response_poster = false; |
||
| 109 | $show_review = true; |
||
| 110 | $jobPoster = $application->job_poster; |
||
| 111 | |||
| 112 | $essential_criteria = $jobPoster->criteria->filter(function ($value, $key) { |
||
| 113 | return $value->criteria_type->name == 'essential' |
||
| 114 | && $value->skill->skill_type->name == 'hard'; |
||
| 115 | }); |
||
| 116 | $asset_criteria = $jobPoster->criteria->filter(function ($value, $key) { |
||
| 117 | return $value->criteria_type->name == 'asset' |
||
| 118 | && $value->skill->skill_type->name == 'hard'; |
||
| 119 | }); |
||
| 120 | |||
| 121 | // Display slightly different views on different portals. |
||
| 122 | $view = WhichPortal::isManagerPortal() || WhichPortal::isHrPortal() ? |
||
| 123 | 'manager/application_post' : 'applicant/application_preview'; |
||
| 124 | |||
| 125 | $application_view = 'common/application/view/view_layout'; |
||
| 126 | |||
| 127 | if (WhichPortal::isManagerPortal() || WhichPortal::isHrPortal()) { |
||
| 128 | // Load things required for review component. |
||
| 129 | $application->load(['veteran_status', 'citizenship_declaration', 'application_review', 'applicant.user']); |
||
| 130 | } |
||
| 131 | |||
| 132 | |||
| 133 | // If the application status is draft then get data through the applicant model. |
||
| 134 | // Else, grab the data from the application itself. |
||
| 135 | if ($application->isDraft()) { |
||
| 136 | $source = $application->applicant; |
||
| 137 | $show_review = false; |
||
| 138 | } else { |
||
| 139 | $source = $application; |
||
| 140 | } |
||
| 141 | |||
| 142 | $degrees = $source->degrees; |
||
| 143 | $courses = $source->courses; |
||
| 144 | $work_experiences = $source->work_experiences; |
||
| 145 | $skill_declarations = $source->skill_declarations; |
||
| 146 | $references = $source->references; |
||
| 147 | $work_samples = $source->work_samples; |
||
| 148 | |||
| 149 | $custom_breadcrumbs = [ |
||
| 150 | 'home' => route('home'), |
||
| 151 | 'applications' => route('applications.index'), |
||
| 152 | 'application' => '', |
||
| 153 | ]; |
||
| 154 | |||
| 155 | if (WhichPortal::isManagerPortal() || WhichPortal::isHrPortal()) { |
||
| 156 | $custom_breadcrumbs = [ |
||
| 157 | 'home' => route('home'), |
||
| 158 | 'jobs' => route(WhichPortal::prefixRoute('jobs.index')), |
||
| 159 | $jobPoster->title => route(WhichPortal::prefixRoute('jobs.summary'), $jobPoster), |
||
| 160 | 'applications' => route(WhichPortal::prefixRoute('jobs.applications'), $jobPoster), |
||
| 161 | 'application' => '', |
||
| 162 | ]; |
||
| 163 | } |
||
| 164 | |||
| 165 | return view( |
||
| 166 | $view, |
||
| 167 | [ |
||
| 168 | 'application_view_template' => $application_view, |
||
| 169 | // Localized strings. |
||
| 170 | 'post' => Lang::get('manager/application_post'), // Change text |
||
| 171 | 'is_manager_view' => WhichPortal::isManagerPortal(), |
||
| 172 | 'is_hr_portal' => WhichPortal::isHrPortal(), |
||
| 173 | // Application Template Data. |
||
| 174 | 'application_template' => Lang::get('applicant/application_template'), |
||
| 175 | 'citizenship_declaration_template' => Lang::get('common/citizenship_declaration'), |
||
| 176 | 'veteran_status_template' => Lang::get('common/veteran_status'), |
||
| 177 | // Job Data. |
||
| 178 | 'job' => $jobPoster, |
||
| 179 | // Skills Data. |
||
| 180 | 'skills' => Skill::all(), |
||
| 181 | 'skill_template' => Lang::get('common/skills'), |
||
| 182 | 'reference_template' => Lang::get('common/references'), |
||
| 183 | 'sample_template' => Lang::get('common/work_samples'), |
||
| 184 | 'essential_criteria' => $essential_criteria, |
||
| 185 | 'asset_criteria' => $asset_criteria, |
||
| 186 | // Applicant Data. |
||
| 187 | 'applicant' => $application->applicant, |
||
| 188 | 'job_application' => $application, |
||
| 189 | 'degrees' => $degrees, |
||
| 190 | 'courses' => $courses, |
||
| 191 | 'work_experiences' => $work_experiences, |
||
| 192 | 'skill_declarations' => $skill_declarations, |
||
| 193 | 'references' => $references, |
||
| 194 | 'work_samples' => $work_samples, |
||
| 195 | 'review_statuses' => ReviewStatus::all(), |
||
| 196 | 'custom_breadcrumbs' => $custom_breadcrumbs, |
||
| 197 | 'response_poster' => $response_poster, |
||
| 198 | 'show_review' => $show_review, |
||
| 199 | ] |
||
| 225 |