Conditions | 14 |
Paths | 1024 |
Total Lines | 43 |
Code Lines | 28 |
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 |
||
43 | private function updateSupplier(EditSupplier $command, Supplier $supplier): Supplier |
||
44 | { |
||
45 | if ($supplier->name() !== $command->name()) { |
||
|
|||
46 | $supplier->renameSupplier($command->name()); |
||
47 | } |
||
48 | if ($supplier->address() !== $command->address() |
||
49 | || ($supplier->zipCode() !== $command->zipCode()) |
||
50 | || ($supplier->town() !== $command->town()) |
||
51 | || ($supplier->country() !== $command->country()) |
||
52 | ) { |
||
53 | $supplier->rewriteAddress([ |
||
54 | $command->address(), |
||
55 | $command->zipCode(), |
||
56 | $command->town(), |
||
57 | $command->country(), |
||
58 | ]); |
||
59 | } |
||
60 | if ($supplier->phone() !== $command->phone()) { |
||
61 | $supplier->changePhoneNumber($command->phone()); |
||
62 | } |
||
63 | if ($supplier->facsimile() !== $command->facsimile()) { |
||
64 | $supplier->changeFacsimileNumber($command->facsimile()); |
||
65 | } |
||
66 | if ($supplier->email() !== $command->email()) { |
||
67 | $supplier->rewriteEmail($command->email()); |
||
68 | } |
||
69 | if ($supplier->contact() !== $command->contact()) { |
||
70 | $supplier->renameContact($command->contact()); |
||
71 | } |
||
72 | if ($supplier->cellPhone() !== $command->cellPhone()) { |
||
73 | $supplier->changeCellphoneNumber($command->cellPhone()); |
||
74 | } |
||
75 | if ($supplier->familyLog() !== $command->familyLog()) { |
||
76 | $supplier->reassignFamilyLog($command->familyLog()); |
||
77 | } |
||
78 | if ($supplier->delayDelivery() !== $command->delayDelivery()) { |
||
79 | $supplier->changeDelayDelivery($command->delayDelivery()); |
||
80 | } |
||
81 | if ($supplier->orderDays() !== $command->orderDays()) { |
||
82 | $supplier->reassignOrderDays($command->orderDays()); |
||
83 | } |
||
84 | |||
85 | return $supplier; |
||
86 | } |
||
88 |