Conditions | 11 |
Paths | 128 |
Total Lines | 34 |
Code Lines | 22 |
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 update(EditCompany $command, Company $company): Company |
||
41 | { |
||
42 | if ($company->name() !== $command->name()) { |
||
|
|||
43 | $company->renameCompany($command->name()); |
||
44 | } |
||
45 | if (($company->address() !== $command->address()) |
||
46 | || ($company->zipCode() !== $command->zipCode()) |
||
47 | || ($company->town() !== $command->town()) |
||
48 | || ($company->country() !== $command->country()) |
||
49 | ) { |
||
50 | $company->rewriteAddress([ |
||
51 | $command->address(), |
||
52 | $command->zipCode(), |
||
53 | $command->town(), |
||
54 | $command->country(), |
||
55 | ]); |
||
56 | } |
||
57 | if ($company->phone() !== $command->phone()) { |
||
58 | $company->changePhoneNumber($command->phone()); |
||
59 | } |
||
60 | if ($company->facsimile() !== $command->facsimile()) { |
||
61 | $company->changeFacsimileNumber($command->facsimile()); |
||
62 | } |
||
63 | if ($company->email() !== $command->email()) { |
||
64 | $company->rewriteEmail($command->email()); |
||
65 | } |
||
66 | if ($company->contact() !== $command->contact()) { |
||
67 | $company->renameContact($command->contact()); |
||
68 | } |
||
69 | if ($company->cellPhone() !== $command->cellPhone()) { |
||
70 | $company->changeCellphoneNumber($command->cellPhone()); |
||
71 | } |
||
72 | |||
73 | return $company; |
||
74 | } |
||
76 |