Skip to content

Instantly share code, notes, and snippets.

@jakeasmith
Last active December 13, 2015 19:38
Show Gist options
  • Save jakeasmith/4964318 to your computer and use it in GitHub Desktop.
Save jakeasmith/4964318 to your computer and use it in GitHub Desktop.
Super simple example of how to implement a system that can handle multiple types of fraud checks
<?php
/*
* Fraud levels:
* 0 - no fraud
* 1 - needs to be reviewed
* 2 - denied
*/
// Set the initial fraud status to zero
$fraud_status = 0;
// Loop thru our fraud checks
foreach($fraud_checks as $check) {
// Run the check
$check_status = $check->run();
// Elevate the fraud status, if needed
if($check_status > $fraud_status)
$fraud_status = $check_status
// Don't waste time running more checks if we already know its fraud
if($check_status === 2)
break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment