| Conditions | 1 |
| Paths | 1 |
| Total Lines | 96 |
| Code Lines | 84 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 |
||
| 14 | public function run() |
||
| 15 | { |
||
| 16 | // Create the test users |
||
| 17 | $emp1 = new User(); |
||
| 18 | $emp1->user_id = 2; |
||
| 19 | $emp1->username = 'admin'; |
||
| 20 | $emp1->first_name = 'Administrator'; |
||
| 21 | $emp1->last_name = 'User'; |
||
| 22 | $emp1->email = '[email protected]'; |
||
| 23 | $emp1->password = bcrypt('password'); |
||
| 24 | $emp1->active = 1; |
||
| 25 | $emp1->save(); |
||
| 26 | UserPermissions::create( |
||
| 27 | [ |
||
| 28 | 'user_id' => 2, |
||
| 29 | 'manage_users' => 0, |
||
| 30 | 'run_reports' => 1, |
||
| 31 | 'add_customer' => 1, |
||
| 32 | 'deactivate_customer' => 0, |
||
| 33 | 'use_file_links' => 1, |
||
| 34 | 'create_tech_tip' => 1, |
||
| 35 | 'edit_tech_tip' => 0, |
||
| 36 | 'delete_tech_tip' => 0, |
||
| 37 | 'create_category' => 0, |
||
| 38 | 'modify_category' => 0 |
||
| 39 | ]); |
||
| 40 | |||
| 41 | $emp2 = new User(); |
||
| 42 | $emp1->user_id = 3; |
||
| 43 | $emp2->username = 'jeverett'; |
||
| 44 | $emp2->first_name = 'Joshua'; |
||
| 45 | $emp2->last_name = 'Everett'; |
||
| 46 | $emp2->email = '[email protected]'; |
||
| 47 | $emp2->password = bcrypt('password'); |
||
| 48 | $emp2->active = 1; |
||
| 49 | $emp2->save(); |
||
| 50 | UserPermissions::create( |
||
| 51 | [ |
||
| 52 | 'user_id' => 3, |
||
| 53 | 'manage_users' => 0, |
||
| 54 | 'run_reports' => 1, |
||
| 55 | 'add_customer' => 1, |
||
| 56 | 'deactivate_customer' => 0, |
||
| 57 | 'use_file_links' => 1, |
||
| 58 | 'create_tech_tip' => 1, |
||
| 59 | 'edit_tech_tip' => 0, |
||
| 60 | 'delete_tech_tip' => 0, |
||
| 61 | 'create_category' => 0, |
||
| 62 | 'modify_category' => 0 |
||
| 63 | ]); |
||
| 64 | $emp3 = new User(); |
||
| 65 | $emp1->user_id = 4; |
||
| 66 | $emp3->username = 'elindsay'; |
||
| 67 | $emp3->first_name = 'Everett'; |
||
| 68 | $emp3->last_name = 'Lindsay'; |
||
| 69 | $emp3->email = '[email protected]'; |
||
| 70 | $emp3->password = bcrypt('password'); |
||
| 71 | $emp3->active = 1; |
||
| 72 | $emp3->save(); |
||
| 73 | UserPermissions::create( |
||
| 74 | [ |
||
| 75 | 'user_id' => 4, |
||
| 76 | 'manage_users' => 0, |
||
| 77 | 'run_reports' => 1, |
||
| 78 | 'add_customer' => 1, |
||
| 79 | 'deactivate_customer' => 0, |
||
| 80 | 'use_file_links' => 1, |
||
| 81 | 'create_tech_tip' => 1, |
||
| 82 | 'edit_tech_tip' => 0, |
||
| 83 | 'delete_tech_tip' => 0, |
||
| 84 | 'create_category' => 0, |
||
| 85 | 'modify_category' => 0 |
||
| 86 | ]); |
||
| 87 | |||
| 88 | $emp4 = new User(); |
||
| 89 | $emp4->user_id = 5; |
||
| 90 | $emp4->username = 'bbob'; |
||
| 91 | $emp4->first_name = 'Billy'; |
||
| 92 | $emp4->last_name = 'Bob'; |
||
| 93 | $emp4->email = '[email protected]'; |
||
| 94 | $emp4->password = bcrypt('password'); |
||
| 95 | $emp4->active = 1; |
||
| 96 | $emp4->save(); |
||
| 97 | UserPermissions::create( |
||
| 98 | [ |
||
| 99 | 'user_id' => 5, |
||
| 100 | 'manage_users' => 0, |
||
| 101 | 'run_reports' => 1, |
||
| 102 | 'add_customer' => 1, |
||
| 103 | 'deactivate_customer' => 0, |
||
| 104 | 'use_file_links' => 1, |
||
| 105 | 'create_tech_tip' => 1, |
||
| 106 | 'edit_tech_tip' => 0, |
||
| 107 | 'delete_tech_tip' => 0, |
||
| 108 | 'create_category' => 0, |
||
| 109 | 'modify_category' => 0 |
||
| 110 | ]); |
||
| 113 |