Skip to content

Instantly share code, notes, and snippets.

@hungtrinh
Created November 3, 2019 16:00
Show Gist options
  • Save hungtrinh/7ad8e1df263fbde50801a7df0fe5c4ee to your computer and use it in GitHub Desktop.
Save hungtrinh/7ad8e1df263fbde50801a7df0fe5c4ee to your computer and use it in GitHub Desktop.
Final Production Code (Testable)
<?php
function discountRateByMembershipType ($membershipType) {
if ('platinum' === $membershipType) return 0.15;
if ('gold' === $membershipType) return 0.1;
if ('silver' === $membershipType) return 0.05;
throw new UnexpectedValueException('invalid membership type');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment