| Conditions | 2 |
| Paths | 2 |
| Total Lines | 59 |
| Code Lines | 45 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 49 | public function load(ObjectManager $manager) |
||
| 50 | { |
||
| 51 | $utilService = new UtilService(); |
||
| 52 | |||
| 53 | $dataArray = array( |
||
| 54 | array( |
||
| 55 | 'name' => 'Project One', |
||
| 56 | 'token' => '1f4ffb19e4b9-02278af07b7d-4e370a76f001', |
||
| 57 | 'email' => '[email protected]', |
||
| 58 | ), |
||
| 59 | array( |
||
| 60 | 'name' => 'Project Two', |
||
| 61 | 'token' => '1f4ffb19e4b9-02278af07b7d-4e370a76f002', |
||
| 62 | 'email' => '[email protected]', |
||
| 63 | ), |
||
| 64 | array( |
||
| 65 | 'name' => 'Project Three', |
||
| 66 | 'token' => '1f4ffb19e4b9-02278af07b7d-4e370a76f003', |
||
| 67 | 'email' => '[email protected]', |
||
| 68 | ), |
||
| 69 | array( |
||
| 70 | 'name' => 'Project Four', |
||
| 71 | 'token' => '1f4ffb19e4b9-02278af07b7d-4e370a76f004', |
||
| 72 | 'email' => '[email protected]', |
||
| 73 | ), |
||
| 74 | array( |
||
| 75 | 'name' => 'Project Five', |
||
| 76 | 'token' => '1f4ffb19e4b9-02278af07b7d-4e370a76f005', |
||
| 77 | 'email' => '[email protected]', |
||
| 78 | ), |
||
| 79 | array( |
||
| 80 | 'name' => 'Project Six', |
||
| 81 | 'token' => '1f4ffb19e4b9-02278af07b7d-4e370a76f006', |
||
| 82 | 'email' => '[email protected]', |
||
| 83 | ), |
||
| 84 | array( |
||
| 85 | 'name' => 'Project Seven', |
||
| 86 | 'token' => '1f4ffb19e4b9-02278af07b7d-4e370a76f007', |
||
| 87 | 'email' => '[email protected]', |
||
| 88 | ), |
||
| 89 | array( |
||
| 90 | 'name' => 'Project Eight', |
||
| 91 | 'token' => '1f4ffb19e4b9-02278af07b7d-4e370a76f008', |
||
| 92 | 'email' => '[email protected]', |
||
| 93 | ), |
||
| 94 | ); |
||
| 95 | $objectList = array(); |
||
| 96 | foreach ($dataArray as $i => $data) { |
||
| 97 | $objectList[$i] = new Project(); |
||
| 98 | $objectList[$i]->setName($data['name']); |
||
| 99 | $objectList[$i]->setRefid($utilService->toAscii($data['name'])); |
||
| 100 | $objectList[$i]->setToken($data['token']); |
||
| 101 | $objectList[$i]->setEmail($data['email']); |
||
| 102 | |||
| 103 | $manager->persist($objectList[$i]); |
||
| 104 | $ref = strtolower(str_replace(' ', '', $data['name'])).'-project'; |
||
| 105 | $this->addReference($ref, $objectList[$i]); |
||
| 106 | } |
||
| 107 | $manager->flush(); |
||
| 108 | } |
||
| 120 |