| Conditions | 1 |
| Paths | 1 |
| Total Lines | 55 |
| Code Lines | 39 |
| 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 |
||
| 40 | public function load(ObjectManager $manager) |
||
| 41 | { |
||
| 42 | $this->em->getConnection()->exec("ALTER TABLE `label_profiles` AUTO_INCREMENT = 1;"); |
||
| 43 | |||
| 44 | $profile1 = new LabelProfile(); |
||
| 45 | $profile1->setName('Profile 1'); |
||
| 46 | $profile1->setShowInDropdown(true); |
||
| 47 | |||
| 48 | $option1 = new LabelOptions(); |
||
| 49 | $option1->setLines("[[NAME]]\n[[DESCRIPION]]"); |
||
| 50 | $option1->setBarcodeType('none'); |
||
| 51 | $option1->setSupportedElement('part'); |
||
| 52 | $profile1->setOptions($option1); |
||
| 53 | |||
| 54 | $manager->persist($profile1); |
||
| 55 | |||
| 56 | $profile2 = new LabelProfile(); |
||
| 57 | $profile2->setName('Profile 2'); |
||
| 58 | $profile2->setShowInDropdown(false); |
||
| 59 | |||
| 60 | $option2 = new LabelOptions(); |
||
| 61 | $option2->setLines("[[NAME]]\n[[DESCRIPION]]"); |
||
| 62 | $option2->setBarcodeType('qr'); |
||
| 63 | $option2->setSupportedElement('part'); |
||
| 64 | $profile2->setOptions($option2); |
||
| 65 | |||
| 66 | $manager->persist($profile2); |
||
| 67 | |||
| 68 | $profile3 = new LabelProfile(); |
||
| 69 | $profile3->setName('Profile 3'); |
||
| 70 | $profile3->setShowInDropdown(true); |
||
| 71 | |||
| 72 | $option3 = new LabelOptions(); |
||
| 73 | $option3->setLines("[[NAME]]\n[[DESCRIPION]]"); |
||
| 74 | $option3->setBarcodeType('code128'); |
||
| 75 | $option3->setSupportedElement('part_lot'); |
||
| 76 | $profile3->setOptions($option3); |
||
| 77 | |||
| 78 | $manager->persist($profile3); |
||
| 79 | |||
| 80 | |||
| 81 | $profile4 = new LabelProfile(); |
||
| 82 | $profile4->setName('Profile 4'); |
||
| 83 | $profile4->setShowInDropdown(true); |
||
| 84 | |||
| 85 | $option4 = new LabelOptions(); |
||
| 86 | $option4->setLines("{{ element.name }}"); |
||
| 87 | $option4->setBarcodeType('code39'); |
||
| 88 | $option4->setSupportedElement('part'); |
||
| 89 | $option4->setLinesMode('twig'); |
||
| 90 | $profile4->setOptions($option4); |
||
| 91 | |||
| 92 | $manager->persist($profile4); |
||
| 93 | |||
| 94 | $manager->flush(); |
||
| 95 | } |
||
| 96 | } |