Conditions | 2 |
Paths | 2 |
Total Lines | 55 |
Code Lines | 37 |
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 |
||
46 | public function build() |
||
47 | { |
||
48 | // Get emails of all Hr Advisors who have claimed job. |
||
49 | $hr_advisors_emails = []; |
||
50 | $hr_advisors = $this->job->hr_advisors; |
||
51 | |||
52 | foreach ($hr_advisors as $advisor) { |
||
53 | $email = User::where('id', $advisor->user_id)->first()->email; |
||
54 | array_push($hr_advisors_emails, $email); |
||
55 | } |
||
56 | |||
57 | // Get date 2 weeks after job poster closes. |
||
58 | $date_in_two_weeks = humanizeLastDay($this->job->close_date_time->addWeeks(2)); |
||
59 | $date_in_two_weeks_fr = humanizeLastDay($this->job->close_date_time->addWeeks(2), 'fr'); |
||
60 | |||
61 | // Number of applicants. |
||
62 | $num_of_applicants = $this->job->job_applications->count(); |
||
63 | |||
64 | // Number of non-citizens. |
||
65 | $canadian_citizen = CitizenshipDeclaration::where('name', 'citizen')->first()->id; |
||
66 | $num_of_noncitizens = $this->job->job_applications |
||
67 | ->where('citizenship_declaration_id', '!=', $canadian_citizen) |
||
68 | ->count(); |
||
69 | |||
70 | // Number of veterans. |
||
71 | $non_veteran = VeteranStatus::where('name', 'none')->first()->id; |
||
72 | $num_of_veterans = $this->job->job_applications |
||
73 | ->where('veteran_status_id', '!=', $non_veteran) |
||
74 | ->count(); |
||
75 | |||
76 | $position = $this->job->getTranslations('title'); |
||
77 | $classification = $this->job->getClassificationMessageAttribute(); |
||
78 | $subject = Lang::get('common/notifications/screen_candidates.subject', [ 'position' => $position['en'], 'classification' => $classification ]) . ' / ' . Lang::get('common/notifications/screen_candidates.subject', [ 'position' => $position['fr'], 'classification' => $classification ], 'fr'); |
||
79 | |||
80 | return $this->subject($subject) |
||
81 | ->cc($hr_advisors_emails) |
||
82 | ->cc(config('mail.admin_address')) |
||
|
|||
83 | ->markdown('emails.job_posters.screen_candidates_plain', [ |
||
84 | 'drop_off_date' => [ |
||
85 | 'en' => $date_in_two_weeks, |
||
86 | 'fr' => $date_in_two_weeks_fr, |
||
87 | ], |
||
88 | 'manager_portal_link' => [ |
||
89 | 'en' => route('manager.home'), |
||
90 | 'fr' => LaravelLocalization::getLocalizedURL('fr', route('manager.home')), |
||
91 | ], |
||
92 | 'num_of_applicants' => $num_of_applicants, |
||
93 | 'num_of_noncitizens' => $num_of_noncitizens, |
||
94 | 'num_of_veterans' => $num_of_veterans, |
||
95 | 'position' => $position, |
||
96 | 'position_link' => [ |
||
97 | 'en' => route('jobs.summary', $this->job->id), |
||
98 | 'fr' => LaravelLocalization::getLocalizedURL('fr', route('jobs.summary', $this->job->id)), |
||
99 | ], |
||
100 | 'talent_cloud_email' => config('mail.admin_address'), |
||
101 | ]); |
||
104 |