Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6779031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:20:12+00:00 2026-05-26T16:20:12+00:00

For example, I have several different merchant clients who I handle transactions for. They

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:20:13+00:00Added an answer on May 26, 2026 at 4:20 pm

    Looks like you’re looking for something like the Strategy pattern.

    You should define an interface for your Fraud classes that accept a $merchId:

    interface Fraud {
        public function check($merchId);
    }
    

    Then implement each subclass:

    class InvalidCheckFraud implements Fraud {
        public function check($merchId) {
            // do something and return
            return true;
        }
    }
    
    class NotAMemberFraud implements Fraud
    {
        public function check($merchId) {
            // do something and return
            return false;
        }
    }
    

    Then, create a context class that checks for each one:

    class FraudContext implements Fraud {
        protected $_frauds = array();    
    
        public function addFraud(Fraud $fraud) {
            $this->_frauds[] = $fraud;
        }
    
        public function check($merchId) {
            foreach ($this->_frauds as $fraud) {
                if (!$fraud->check($merchId)) {
                    throw new LogicException(
                      "{$merchId} has failed the check for ".get_class($fraud)
                    );
                }
            }
            return true;
        }
    }
    
    $merchId = 42;
    $context = new FraudContext;
    $context->addFraud(new InvalidCheckFraud);
    $context->addFraud(new NotAMemberFRaud);
    $context->check($merchId);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several different entities I want to index in SOLR, for example: users
I have several sites in different domains: example.com , example.org , mail.example.com and passport.example.org
I have a client who has a web service providing several different top-level entities.
we have several internal p2 repositories. Each repository has many versions of different features.
I have tried several different ways to get a simple DataTemplate example to work.
I have a couple of ANT projects for several different clients; the directory structure
I have several web pages on several different sites that I want to mirror
I have several delimiters. For example {del1, del2, del3 }. Suppose I have text
There have been several questions posted to SO about floating-point representation. For example, the
I have made modifications to several example OpenCV projects within Android, however I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.