Conditions | 4 |
Paths | 8 |
Total Lines | 82 |
Code Lines | 59 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 0 | Features | 1 |
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 |
||
33 | public function run() |
||
34 | { |
||
35 | $faker = $this->faker; |
||
36 | $faker_fr = $this->faker_fr; |
||
37 | |||
38 | $job = new JobPoster(); |
||
39 | $job->manager_id = Manager::inRandomOrder()->first()->id; |
||
40 | $job->fill([ |
||
41 | 'published' => true, |
||
42 | 'job_term_id' => JobTerm::inRandomOrder()->first()->id, |
||
43 | 'term_qty' => $faker->numberBetween(1, 4), |
||
44 | 'open_date_time' => $faker->dateTimeBetween('-1 months','now'), |
||
45 | 'close_date_time' => $faker->dateTimeBetween('now', '1 months'), |
||
46 | 'start_date_time' => $faker->dateTimeBetween('1 months','2 months'), |
||
47 | 'department_id' => Department::inRandomOrder()->first()->id, |
||
48 | 'province_id' => Province::inRandomOrder()->first()->id, |
||
49 | 'salary_min' => $faker->numberBetween(60000, 80000), |
||
50 | 'salary_max' => $faker->numberBetween(80000,100000), |
||
51 | 'noc' => $faker->numberBetween(1, 9999), |
||
52 | 'classification' => $faker->regexify('[A-Z]{2}-0[1-5]'), |
||
53 | 'security_clearance_id' => SecurityClearance::inRandomOrder()->first()->id, |
||
54 | 'language_requirement_id' => LanguageRequirement::inRandomOrder()->first()->id, |
||
55 | 'en' => [ |
||
56 | 'city' => $faker->city(), |
||
57 | 'title' => $faker->word(), |
||
58 | 'impact' => $faker->paragraphs(2, true), |
||
59 | 'branch' => $faker->word(), |
||
60 | 'division' => $faker->word() |
||
61 | ], |
||
62 | 'fr' => [ |
||
63 | 'city' => $faker_fr->city(), |
||
64 | 'title' => $faker_fr->word(), |
||
65 | 'impact' => $faker_fr->paragraphs(2, true), |
||
66 | 'branch' => $faker_fr->word(), |
||
67 | 'division' => $faker_fr->word() |
||
68 | ] |
||
69 | ]); |
||
70 | |||
71 | $job->save(); |
||
72 | |||
73 | //Create 3-6 criteria |
||
74 | for($i=0; $i< $faker->numberBetween(3,6); $i++) { |
||
75 | $criteria = new Criteria(); |
||
76 | $criteria->criteria_type_id = CriteriaType::inRandomOrder()->first()->id; |
||
77 | $criteria->job_poster_id = $job->id; |
||
78 | $criteria->skill_id = Skill::inRandomOrder()->first()->id; |
||
79 | $criteria->skill_level_id = SkillLevel::inRandomOrder()->first()->id; |
||
80 | $criteria->save(); |
||
81 | } |
||
82 | |||
83 | //Create 2-4 key tasks |
||
84 | for($i=0; $i< $faker->numberBetween(2,4); $i++) { |
||
85 | $keyTask = new JobPosterKeyTask(); |
||
86 | $keyTask->job_poster_id = $job->id; |
||
87 | $keyTask->fill([ |
||
88 | 'en' => [ |
||
89 | 'description' => $faker->sentence() |
||
90 | ], |
||
91 | 'fr' => [ |
||
92 | 'description' => $faker_fr->sentence() |
||
93 | ] |
||
94 | |||
95 | ]); |
||
96 | $keyTask->save(); |
||
97 | } |
||
98 | |||
99 | //Create 2-3 questions tasks |
||
100 | for($i=0; $i< $faker->numberBetween(2,3); $i++) { |
||
101 | $question = new JobPosterQuestion(); |
||
102 | $question->job_poster_id = $job->id; |
||
103 | $question->fill([ |
||
104 | 'en' => [ |
||
105 | 'question' => $faker->sentence(), |
||
106 | 'description' => $faker->paragraph() |
||
107 | ], |
||
108 | 'fr' => [ |
||
109 | 'question' => $faker->sentence(), |
||
110 | 'description' => $faker->paragraph() |
||
111 | ] |
||
112 | |||
113 | ]); |
||
114 | $question->save(); |
||
115 | } |
||
118 |