Conditions | 1 |
Paths | 1 |
Total Lines | 61 |
Code Lines | 45 |
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 |
||
27 | public function load(ObjectManager $manager) |
||
28 | { |
||
29 | //Reset autoincrement |
||
30 | $this->em->getConnection() |
||
31 | ->exec('ALTER TABLE `user` AUTO_INCREMENT = 1;'); |
||
32 | |||
33 | $user = new User(); |
||
34 | $user->setUsername('admin'); |
||
35 | //We use plaintext encoder so we can just set the PW here |
||
36 | $user->setPassword($this->passwordEncoder->encodePassword($user, '1234')); |
||
37 | $user->setFirstName('Admin'); |
||
38 | $user->setLastName('User'); |
||
39 | $user->setRoles(['ROLE_ADMIN', |
||
40 | 'ROLE_EDIT_USER', |
||
41 | 'ROLE_EDIT_ORGANISATIONS', |
||
42 | 'ROLE_SHOW_PAYMENT_ORDERS', |
||
43 | 'ROLE_EDIT_PAYMENT_ORDERS', |
||
44 | 'ROLE_PO_FACTUALLY', |
||
45 | 'ROLE_PO_MATHEMATICALLY', |
||
46 | 'ROLE_EDIT_BANK_ACCOUNTS', |
||
47 | ]); |
||
48 | $this->addReference(self::USER_ADMIN_REFERENCE, $user); |
||
49 | $manager->persist($user); |
||
50 | |||
51 | $user = new User(); |
||
52 | $user->setUsername('hhv'); |
||
53 | //We use plaintext encoder so we can just set the PW here |
||
54 | $user->setPassword($this->passwordEncoder->encodePassword($user, '1234')); |
||
55 | $user->setRoles(['ROLE_ADMIN', |
||
56 | 'ROLE_EDIT_ORGANISATIONS', |
||
57 | 'ROLE_SHOW_PAYMENT_ORDERS', |
||
58 | 'ROLE_EDIT_PAYMENT_ORDERS', |
||
59 | 'ROLE_PO_FACTUALLY', |
||
60 | 'ROLE_EDIT_BANK_ACCOUNTS', |
||
61 | ]); |
||
62 | $this->addReference(self::USER_HHV_REFERENCE, $user); |
||
63 | $manager->persist($user); |
||
64 | |||
65 | $user = new User(); |
||
66 | $user->setUsername('exporter'); |
||
67 | //We use plaintext encoder so we can just set the PW here |
||
68 | $user->setPassword($this->passwordEncoder->encodePassword($user, '1234')); |
||
69 | $user->setRoles(['ROLE_ADMIN', |
||
70 | 'ROLE_SHOW_PAYMENT_ORDERS', |
||
71 | 'ROLE_EDIT_PAYMENT_ORDERS', |
||
72 | 'ROLE_PO_MATHEMATICALLY', |
||
73 | ]); |
||
74 | $this->addReference(self::USER_EXPORTER_REFERENCE, $user); |
||
75 | $manager->persist($user); |
||
76 | |||
77 | $user = new User(); |
||
78 | $user->setUsername('readonly'); |
||
79 | //We use plaintext encoder so we can just set the PW here |
||
80 | $user->setPassword($this->passwordEncoder->encodePassword($user, '1234')); |
||
81 | $user->setRoles(['ROLE_ADMIN', |
||
82 | 'ROLE_SHOW_PAYMENT_ORDERS', |
||
83 | ]); |
||
84 | $this->addReference(self::USER_READONLY_REFERENCE, $user); |
||
85 | $manager->persist($user); |
||
86 | |||
87 | $manager->flush(); |
||
88 | } |
||
90 |