| Conditions | 1 |
| Paths | 1 |
| Total Lines | 109 |
| Code Lines | 97 |
| 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 | |||
| 26 | $payment_order = new PaymentOrder(); |
||
| 27 | $payment_order->setFirstName('John'); |
||
| 28 | $payment_order->setLastName('Doe'); |
||
| 29 | $payment_order->setContactEmail('[email protected]'); |
||
| 30 | $payment_order->setFundingId('M-123-2020'); |
||
| 31 | $payment_order->setProjectName('Test'); |
||
| 32 | $payment_order->setFsrKomResolution(true); |
||
| 33 | $payment_order->setDepartment($this->getReference(DepartmentFixture::DEPARTMENT3_REFERENCE)); |
||
| 34 | $payment_order->setAmount(12340); |
||
| 35 | $payment_order->setComment('Test'); |
||
| 36 | $payment_order->setConfirm1Token(password_hash('token1', PASSWORD_DEFAULT)); |
||
| 37 | $payment_order->setConfirm2Token(password_hash('token2', PASSWORD_DEFAULT)); |
||
| 38 | $payment_order->getBankInfo() |
||
| 39 | ->setAccountOwner('John Doe'); |
||
| 40 | $payment_order->getBankInfo() |
||
| 41 | ->setIban('DE98 5001 0517 4783 9248 44'); |
||
| 42 | $payment_order->getBankInfo() |
||
| 43 | ->setStreet('Street 1'); |
||
| 44 | $payment_order->getBankInfo() |
||
| 45 | ->setZipCode('12345'); |
||
| 46 | $payment_order->getBankInfo() |
||
| 47 | ->setCity('Jena'); |
||
| 48 | |||
| 49 | $this->addFiles($payment_order); |
||
| 50 | $manager->persist($payment_order); |
||
| 51 | |||
| 52 | $payment_order = new PaymentOrder(); |
||
| 53 | $payment_order->setFirstName('John'); |
||
| 54 | $payment_order->setLastName('Doe'); |
||
| 55 | $payment_order->setContactEmail('[email protected]'); |
||
| 56 | $payment_order->setFundingId(''); |
||
| 57 | $payment_order->setProjectName('Test'); |
||
| 58 | $payment_order->setFsrKomResolution(false); |
||
| 59 | $payment_order->setDepartment($this->getReference(DepartmentFixture::DEPARTMENT2_REFERENCE)); |
||
| 60 | $payment_order->setAmount(12340); |
||
| 61 | $payment_order->setComment('Test'); |
||
| 62 | $payment_order->setConfirm1Token(password_hash('token1', PASSWORD_DEFAULT)); |
||
| 63 | $payment_order->setConfirm2Token(null); |
||
| 64 | $payment_order->getBankInfo() |
||
| 65 | ->setAccountOwner('John Doe'); |
||
| 66 | $payment_order->getBankInfo() |
||
| 67 | ->setIban('DE98 5001 0517 4783 9248 44'); |
||
| 68 | $payment_order->getBankInfo() |
||
| 69 | ->setStreet('Street 1'); |
||
| 70 | $payment_order->getBankInfo() |
||
| 71 | ->setZipCode('12345'); |
||
| 72 | $payment_order->getBankInfo() |
||
| 73 | ->setCity('Jena'); |
||
| 74 | |||
| 75 | $this->addFiles($payment_order); |
||
| 76 | $manager->persist($payment_order); |
||
| 77 | |||
| 78 | $payment_order = new PaymentOrder(); |
||
| 79 | $payment_order->setFirstName('John'); |
||
| 80 | $payment_order->setLastName('Doe'); |
||
| 81 | $payment_order->setContactEmail('[email protected]'); |
||
| 82 | $payment_order->setFundingId(''); |
||
| 83 | $payment_order->setProjectName('Test23'); |
||
| 84 | $payment_order->setFsrKomResolution(false); |
||
| 85 | $payment_order->setDepartment($this->getReference(DepartmentFixture::DEPARTMENT4_REFERENCE)); |
||
| 86 | $payment_order->setAmount(100); |
||
| 87 | $payment_order->setComment('Test'); |
||
| 88 | $payment_order->getBankInfo() |
||
| 89 | ->setAccountOwner('John Doe'); |
||
| 90 | $payment_order->getBankInfo() |
||
| 91 | ->setIban('DE98500105174783924844'); |
||
| 92 | $payment_order->getBankInfo() |
||
| 93 | ->setBic('INGDDEFFXXX'); |
||
| 94 | $payment_order->getBankInfo() |
||
| 95 | ->setStreet('Street 1'); |
||
| 96 | $payment_order->getBankInfo() |
||
| 97 | ->setZipCode('12345'); |
||
| 98 | $payment_order->getBankInfo() |
||
| 99 | ->setCity('Jena'); |
||
| 100 | |||
| 101 | $this->addFiles($payment_order); |
||
| 102 | $manager->persist($payment_order); |
||
| 103 | |||
| 104 | $payment_order = new PaymentOrder(); |
||
| 105 | $payment_order->setFirstName('John'); |
||
| 106 | $payment_order->setLastName('Doe'); |
||
| 107 | $payment_order->setContactEmail('[email protected]'); |
||
| 108 | $payment_order->setFundingId(''); |
||
| 109 | $payment_order->setProjectName('Test23'); |
||
| 110 | $payment_order->setFsrKomResolution(true); |
||
| 111 | $payment_order->setDepartment($this->getReference(DepartmentFixture::DEPARTMENT5_REFERENCE)); |
||
| 112 | $payment_order->setAmount(10000); |
||
| 113 | $payment_order->setComment(''); |
||
| 114 | $payment_order->getBankInfo() |
||
| 115 | ->setAccountOwner('John Doe'); |
||
| 116 | $payment_order->getBankInfo() |
||
| 117 | ->setIban('DE98 5001 0517 4783 9248 44'); |
||
| 118 | $payment_order->getBankInfo() |
||
| 119 | ->setStreet('Street 1'); |
||
| 120 | $payment_order->getBankInfo() |
||
| 121 | ->setZipCode('12345'); |
||
| 122 | $payment_order->getBankInfo() |
||
| 123 | ->setCity('Jena'); |
||
| 124 | |||
| 125 | $this->addFiles($payment_order); |
||
| 126 | $manager->persist($payment_order); |
||
| 127 | |||
| 128 | $manager->flush(); |
||
| 129 | } |
||
| 152 |