Created
June 1, 2018 04:57
-
-
Save pierswarmers/6bfe23ea374a9d7d645a6203f02f0575 to your computer and use it in GitHub Desktop.
Legacy Refactor with Comparative Analysis
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function processOrder(Order $order): Invoice | |
| { | |
| $invoiceA = $order->processOrderOnLegacyLogic(); | |
| $invoiceB = $order->processOrderOnRefactoredLogic(); | |
| if($invoiceA->getTotal() !== $invoiceB->getTotal()) { | |
| $this->log->error( | |
| 'Invoice comparison failed.', | |
| [ | |
| 'order' => $order, | |
| 'invoiceA' => $invoiceA, | |
| 'invoiceB' => $invoiceB | |
| ] | |
| ); | |
| } | |
| return $invoiceA; | |
| } | |
| function processOrderOnLegacyLogic(Order $order): Invoice | |
| { | |
| // here be dragons | |
| } | |
| function processOrderOnRefactoredLogic() | |
| { | |
| // all that is good | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment