Skip to content

Instantly share code, notes, and snippets.

@pierswarmers
Created June 1, 2018 04:57
Show Gist options
  • Select an option

  • Save pierswarmers/6bfe23ea374a9d7d645a6203f02f0575 to your computer and use it in GitHub Desktop.

Select an option

Save pierswarmers/6bfe23ea374a9d7d645a6203f02f0575 to your computer and use it in GitHub Desktop.
Legacy Refactor with Comparative Analysis
<?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