Conditions | 1 |
Paths | 1 |
Total Lines | 111 |
Code Lines | 98 |
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 |
||
20 | public function load(ObjectManager $manager) |
||
21 | { |
||
22 | //Reset autoincrement |
||
23 | $this->em->getConnection() |
||
|
|||
24 | ->exec('ALTER TABLE `payment_orders` AUTO_INCREMENT = 1;'); |
||
25 | //ALTER TABLE does an implicit commit and PHP 8 throws if commit is called later internally without active transactions |
||
26 | $this->em->getConnection()->beginTransaction(); |
||
27 | |||
28 | $payment_order = new PaymentOrder(); |
||
29 | $payment_order->setFirstName('John'); |
||
30 | $payment_order->setLastName('Doe'); |
||
31 | $payment_order->setContactEmail('[email protected]'); |
||
32 | $payment_order->setFundingId('M-123-2020'); |
||
33 | $payment_order->setProjectName('Test'); |
||
34 | $payment_order->setFsrKomResolution(true); |
||
35 | $payment_order->setDepartment($this->getReference(DepartmentFixture::DEPARTMENT3_REFERENCE)); |
||
36 | $payment_order->setAmount(12340); |
||
37 | $payment_order->setComment('Test'); |
||
38 | $payment_order->setConfirm1Token(password_hash('token1', PASSWORD_DEFAULT)); |
||
39 | $payment_order->setConfirm2Token(password_hash('token2', PASSWORD_DEFAULT)); |
||
40 | $payment_order->getBankInfo() |
||
41 | ->setAccountOwner('John Doe'); |
||
42 | $payment_order->getBankInfo() |
||
43 | ->setIban('DE98 5001 0517 4783 9248 44'); |
||
44 | $payment_order->getBankInfo() |
||
45 | ->setStreet('Street 1'); |
||
46 | $payment_order->getBankInfo() |
||
47 | ->setZipCode('12345'); |
||
48 | $payment_order->getBankInfo() |
||
49 | ->setCity('Jena'); |
||
50 | |||
51 | $this->addFiles($payment_order); |
||
52 | $manager->persist($payment_order); |
||
53 | |||
54 | $payment_order = new PaymentOrder(); |
||
55 | $payment_order->setFirstName('John'); |
||
56 | $payment_order->setLastName('Doe'); |
||
57 | $payment_order->setContactEmail('[email protected]'); |
||
58 | $payment_order->setFundingId(''); |
||
59 | $payment_order->setProjectName('Test'); |
||
60 | $payment_order->setFsrKomResolution(false); |
||
61 | $payment_order->setDepartment($this->getReference(DepartmentFixture::DEPARTMENT2_REFERENCE)); |
||
62 | $payment_order->setAmount(12340); |
||
63 | $payment_order->setComment('Test'); |
||
64 | $payment_order->setConfirm1Token(password_hash('token1', PASSWORD_DEFAULT)); |
||
65 | $payment_order->setConfirm2Token(null); |
||
66 | $payment_order->getBankInfo() |
||
67 | ->setAccountOwner('John Doe'); |
||
68 | $payment_order->getBankInfo() |
||
69 | ->setIban('DE98 5001 0517 4783 9248 44'); |
||
70 | $payment_order->getBankInfo() |
||
71 | ->setStreet('Street 1'); |
||
72 | $payment_order->getBankInfo() |
||
73 | ->setZipCode('12345'); |
||
74 | $payment_order->getBankInfo() |
||
75 | ->setCity('Jena'); |
||
76 | |||
77 | $this->addFiles($payment_order); |
||
78 | $manager->persist($payment_order); |
||
79 | |||
80 | $payment_order = new PaymentOrder(); |
||
81 | $payment_order->setFirstName('John'); |
||
82 | $payment_order->setLastName('Doe'); |
||
83 | $payment_order->setContactEmail('[email protected]'); |
||
84 | $payment_order->setFundingId(''); |
||
85 | $payment_order->setProjectName('Test23'); |
||
86 | $payment_order->setFsrKomResolution(false); |
||
87 | $payment_order->setDepartment($this->getReference(DepartmentFixture::DEPARTMENT4_REFERENCE)); |
||
88 | $payment_order->setAmount(100); |
||
89 | $payment_order->setComment('Test'); |
||
90 | $payment_order->getBankInfo() |
||
91 | ->setAccountOwner('John Doe'); |
||
92 | $payment_order->getBankInfo() |
||
93 | ->setIban('DE98500105174783924844'); |
||
94 | $payment_order->getBankInfo() |
||
95 | ->setBic('INGDDEFFXXX'); |
||
96 | $payment_order->getBankInfo() |
||
97 | ->setStreet('Street 1'); |
||
98 | $payment_order->getBankInfo() |
||
99 | ->setZipCode('12345'); |
||
100 | $payment_order->getBankInfo() |
||
101 | ->setCity('Jena'); |
||
102 | |||
103 | $this->addFiles($payment_order); |
||
104 | $manager->persist($payment_order); |
||
105 | |||
106 | $payment_order = new PaymentOrder(); |
||
107 | $payment_order->setFirstName('John'); |
||
108 | $payment_order->setLastName('Doe'); |
||
109 | $payment_order->setContactEmail('[email protected]'); |
||
110 | $payment_order->setFundingId(''); |
||
111 | $payment_order->setProjectName('Test23'); |
||
112 | $payment_order->setFsrKomResolution(true); |
||
113 | $payment_order->setDepartment($this->getReference(DepartmentFixture::DEPARTMENT5_REFERENCE)); |
||
114 | $payment_order->setAmount(10000); |
||
115 | $payment_order->setComment(''); |
||
116 | $payment_order->getBankInfo() |
||
117 | ->setAccountOwner('John Doe'); |
||
118 | $payment_order->getBankInfo() |
||
119 | ->setIban('DE98 5001 0517 4783 9248 44'); |
||
120 | $payment_order->getBankInfo() |
||
121 | ->setStreet('Street 1'); |
||
122 | $payment_order->getBankInfo() |
||
123 | ->setZipCode('12345'); |
||
124 | $payment_order->getBankInfo() |
||
125 | ->setCity('Jena'); |
||
126 | |||
127 | $this->addFiles($payment_order); |
||
128 | $manager->persist($payment_order); |
||
129 | |||
130 | $manager->flush(); |
||
131 | } |
||
154 |
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.