| Conditions | 1 |
| Paths | 1 |
| Total Lines | 133 |
| Code Lines | 124 |
| 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 |
||
| 37 | public function load(ObjectManager $manager): void |
||
| 38 | { |
||
| 39 | $admins = new Group(); |
||
| 40 | $admins->setName('admins'); |
||
| 41 | //Perm values taken from Version 1 |
||
| 42 | $admins->getPermissions()->setRawPermissionValues([ |
||
| 43 | 'system' => 21, |
||
| 44 | 'groups' => 1365, |
||
| 45 | 'users' => 87381, |
||
| 46 | 'self' => 85, |
||
| 47 | 'config' => 85, |
||
| 48 | 'database' => 21, |
||
| 49 | 'parts' => 1431655765, |
||
| 50 | 'parts_name' => 5, |
||
| 51 | 'parts_description' => 5, |
||
| 52 | 'parts_footprint' => 5, |
||
| 53 | 'parts_manufacturer' => 5, |
||
| 54 | 'parts_comment' => 5, |
||
| 55 | 'parts_order' => 5, |
||
| 56 | 'parts_orderdetails' => 341, |
||
| 57 | 'parts_prices' => 341, |
||
| 58 | 'parts_attachments' => 341, |
||
| 59 | 'devices' => 5461, |
||
| 60 | 'devices_parts' => 325, |
||
| 61 | 'storelocations' => 5461, |
||
| 62 | 'footprints' => 5461, |
||
| 63 | 'categories' => 5461, |
||
| 64 | 'suppliers' => 5461, |
||
| 65 | 'manufacturers' => 5461, |
||
| 66 | 'attachment_types' => 1365, |
||
| 67 | 'tools' => 1365, |
||
| 68 | 'labels' => 21, |
||
| 69 | 'parts_category' => 5, |
||
| 70 | 'parts_minamount' => 5, |
||
| 71 | 'parts_lots' => 85, |
||
| 72 | 'parts_tags' => 5, |
||
| 73 | 'parts_unit' => 5, |
||
| 74 | 'parts_mass' => 5, |
||
| 75 | 'parts_status' => 5, |
||
| 76 | 'parts_mpn' => 5, |
||
| 77 | 'currencies' => 5461, |
||
| 78 | 'measurement_units' => 5461, |
||
| 79 | ]); |
||
| 80 | $this->setReference(self::ADMINS, $admins); |
||
| 81 | $manager->persist($admins); |
||
| 82 | |||
| 83 | $readonly = new Group(); |
||
| 84 | $readonly->setName('readonly'); |
||
| 85 | $readonly->getPermissions()->setRawPermissionValues([ |
||
| 86 | 'system' => 2, |
||
| 87 | 'groups' => 2730, |
||
| 88 | 'users' => 43690, |
||
| 89 | 'self' => 25, |
||
| 90 | 'config' => 170, |
||
| 91 | 'database' => 42, |
||
| 92 | 'parts' => 2778027689, |
||
| 93 | 'parts_name' => 9, |
||
| 94 | 'parts_description' => 9, |
||
| 95 | 'parts_footprint' => 9, |
||
| 96 | 'parts_manufacturer' => 9, |
||
| 97 | 'parts_comment' => 9, |
||
| 98 | 'parts_order' => 9, |
||
| 99 | 'parts_orderdetails' => 681, |
||
| 100 | 'parts_prices' => 681, |
||
| 101 | 'parts_attachments' => 681, |
||
| 102 | 'devices' => 1705, |
||
| 103 | 'devices_parts' => 649, |
||
| 104 | 'storelocations' => 1705, |
||
| 105 | 'footprints' => 1705, |
||
| 106 | 'categories' => 1705, |
||
| 107 | 'suppliers' => 1705, |
||
| 108 | 'manufacturers' => 1705, |
||
| 109 | 'attachment_types' => 681, |
||
| 110 | 'tools' => 1366, |
||
| 111 | 'labels' => 165, |
||
| 112 | 'parts_category' => 9, |
||
| 113 | 'parts_minamount' => 9, |
||
| 114 | 'parts_lots' => 169, |
||
| 115 | 'parts_tags' => 9, |
||
| 116 | 'parts_unit' => 9, |
||
| 117 | 'parts_mass' => 9, |
||
| 118 | 'parts_status' => 9, |
||
| 119 | 'parts_mpn' => 9, |
||
| 120 | 'currencies' => 9897, |
||
| 121 | 'measurement_units' => 9897, |
||
| 122 | ]); |
||
| 123 | $this->setReference(self::READONLY, $readonly); |
||
| 124 | $manager->persist($readonly); |
||
| 125 | |||
| 126 | $users = new Group(); |
||
| 127 | $users->setName('users'); |
||
| 128 | $users->getPermissions()->setRawPermissionValues([ |
||
| 129 | 'system' => 42, |
||
| 130 | 'groups' => 2730, |
||
| 131 | 'users' => 43690, |
||
| 132 | 'self' => 89, |
||
| 133 | 'config' => 105, |
||
| 134 | 'database' => 41, |
||
| 135 | 'parts' => 1431655765, |
||
| 136 | 'parts_name' => 5, |
||
| 137 | 'parts_description' => 5, |
||
| 138 | 'parts_footprint' => 5, |
||
| 139 | 'parts_manufacturer' => 5, |
||
| 140 | 'parts_comment' => 5, |
||
| 141 | 'parts_order' => 5, |
||
| 142 | 'parts_orderdetails' => 341, |
||
| 143 | 'parts_prices' => 341, |
||
| 144 | 'parts_attachments' => 341, |
||
| 145 | 'devices' => 5461, |
||
| 146 | 'devices_parts' => 325, |
||
| 147 | 'storelocations' => 5461, |
||
| 148 | 'footprints' => 5461, |
||
| 149 | 'categories' => 5461, |
||
| 150 | 'suppliers' => 5461, |
||
| 151 | 'manufacturers' => 5461, |
||
| 152 | 'attachment_types' => 1365, |
||
| 153 | 'tools' => 1365, |
||
| 154 | 'labels' => 85, |
||
| 155 | 'parts_category' => 5, |
||
| 156 | 'parts_minamount' => 5, |
||
| 157 | 'parts_lots' => 85, |
||
| 158 | 'parts_tags' => 5, |
||
| 159 | 'parts_unit' => 5, |
||
| 160 | 'parts_mass' => 5, |
||
| 161 | 'parts_status' => 5, |
||
| 162 | 'parts_mpn' => 5, |
||
| 163 | 'currencies' => 5461, |
||
| 164 | 'measurement_units' => 5461, |
||
| 165 | ]); |
||
| 166 | $this->setReference(self::USERS, $users); |
||
| 167 | $manager->persist($users); |
||
| 168 | |||
| 169 | $manager->flush(); |
||
| 170 | } |
||
| 172 |