Skip to content

Instantly share code, notes, and snippets.

@craig-davis
Last active April 15, 2017 17:25
Show Gist options
  • Save craig-davis/606395a2fa1f76c9a84008d4846a87ef to your computer and use it in GitHub Desktop.
Save craig-davis/606395a2fa1f76c9a84008d4846a87ef to your computer and use it in GitHub Desktop.
Code with If/Else and Early Return
<?php
function calculateSalePrice($item, $discount = 0) {
if ($discount == 0) {
return $item->getPrice();
}
else {
return calculateDiscountedPrice($item->getPrice, $discount);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment