For example, I have several different merchant clients who I handle transactions for. They want different metrics for determining fraud, many of which are common. I’d like to have something to the effect of:
class Fraud
{
}
class InvalidCheckFraud extends Fraud
{
}
class NotAMemberFRaud extends Fraud
{
}
class CustomerLooksFunnyFraud extends Fraud
{
}
etc…
I’d like to just be able to run zero to many extended Fraud classes using a command like:
$fraudCheck = new Fraud();
$fraudCheck->checkMerchant($merchId);
I don’t mind solving this in a completely home grown fashion, but if it’s already been figured out, I’d like to go that route.
I’m coding in PHP, but am fine with a reference using any other language.
Looks like you’re looking for something like the Strategy pattern.
You should define an interface for your
Fraudclasses that accept a$merchId:Then implement each subclass:
Then, create a context class that checks for each one: