Last active
April 15, 2017 17:25
-
-
Save craig-davis/606395a2fa1f76c9a84008d4846a87ef to your computer and use it in GitHub Desktop.
Code with If/Else and Early Return
This file contains 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 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