Conditions | 2 |
Paths | 2 |
Total Lines | 52 |
Code Lines | 40 |
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 |
||
35 | public function init() |
||
36 | { |
||
37 | $entityManager = EntityManagerFactory::getEntityManager([ |
||
38 | Company\CompanyPerson::class, |
||
39 | Company\CompanyEmployee::class, |
||
40 | Company\CompanyManager::class, |
||
41 | Company\CompanyOrganization::class, |
||
42 | Company\CompanyEvent::class, |
||
43 | Company\CompanyAuction::class, |
||
44 | Company\CompanyRaffle::class, |
||
45 | Company\CompanyCar::class, |
||
46 | Company\CompanyContract::class, |
||
47 | ]); |
||
48 | |||
49 | $this->contractsRepository = $entityManager->getRepository(Company\CompanyContract::class); |
||
50 | $this->fixContractsRepository = $entityManager->getRepository(Company\CompanyFixContract::class); |
||
51 | $this->flexContractRepository = $entityManager->getRepository(Company\CompanyFlexContract::class); |
||
52 | $this->ultraContractRepository = $entityManager->getRepository(Company\CompanyFlexUltraContract::class); |
||
53 | |||
54 | $person = new Company\CompanyEmployee(); |
||
55 | $person->setName('Poor Sales Guy'); |
||
56 | $person->setDepartment('Sales'); |
||
57 | $person->setSalary(100); |
||
58 | $entityManager->persist($person); |
||
59 | |||
60 | for ($i = 0; $i < 33; $i++) { |
||
61 | $fixContract = new Company\CompanyFixContract(); |
||
62 | $flexContract = new Company\CompanyFlexContract(); |
||
63 | $ultraContract = new Company\CompanyFlexUltraContract(); |
||
64 | |||
65 | $fixContract->setFixPrice(1000); |
||
66 | $fixContract->setSalesPerson($person); |
||
67 | $fixContract->markCompleted(); |
||
68 | |||
69 | $flexContract->setSalesPerson($person); |
||
70 | $flexContract->setHoursWorked(100); |
||
71 | $flexContract->setPricePerHour(100); |
||
72 | $flexContract->markCompleted(); |
||
73 | |||
74 | $ultraContract->setSalesPerson($person); |
||
75 | $ultraContract->setHoursWorked(150); |
||
76 | $ultraContract->setPricePerHour(150); |
||
77 | $ultraContract->setMaxPrice(7000); |
||
78 | |||
79 | $entityManager->persist($fixContract); |
||
80 | $entityManager->persist($flexContract); |
||
81 | $entityManager->persist($ultraContract); |
||
82 | } |
||
83 | |||
84 | $entityManager->flush(); |
||
85 | $entityManager->clear(); |
||
86 | } |
||
87 | |||
108 |