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