need help naming this class and method

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

need help naming this class and method

Post by Luke »

I'm working on some validation / filtering classes. So far we have these classes:

Data
Data_Validate
Data_Filter

I want to write a class that ties Data to Data_Validate and Date_Filter. So some example code would look like:

Code: Select all

$process = new Fp_Data_Process($_POST); // converts $_POST to a Data object

$process->addFilter('FormatCurrency', 'sallary');
$process->addValidator('StringTrim', 'username');

if ($process->filterThenValidate())
{
    echo 'We\'re good,', $process->get('username');
}
else
{
    $errors = $process->getErrorMessages();
    foreach ($errors as $error)
    {
        echo $error;
    }
}
I don't like Data_Process and I don't like filterThenValidate(). What should I name these?
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

cleanify?
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

Data_Purify?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Seems like a Chain/Guantlet-type class.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

I think Chain, Processor or Manager would all be fine. It seems like it should be more like:

Code: Select all

if ($filterchain->isValid()) 

// or

if ($chain->process())
(#10850)
Post Reply