Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@calina-c
Created October 19, 2016 07:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save calina-c/9535b937c459e2de3b45fb97869b6443 to your computer and use it in GitHub Desktop.
Save calina-c/9535b937c459e2de3b45fb97869b6443 to your computer and use it in GitHub Desktop.
Part of IF inversion examples, contains only the untangled version of the function
<?php
function validateApplicationUntangled($user) {
if($user->age<18) {
printf("Sorry, but the user %s is under 18\n", $user->name);
return false;
}
if($user->hasPreviousApplication && $user->previousApplicationApproved) {
printf("Sorry, but the user %s has a previously approved application\n", $user->name);
return false;
}
printf("Cool, application approved for user %s\n", $user->name);
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment