class MUserNew | Add DRY, remove constants to mysql defaults Note, I choose not to use the Factory Pattern out of preference.

This is a ( M ) odel class in the MVC pattern.

Private functions return Booleans and public functions return strings which I then output to the browser from the Controller.  The class returns a string from the invoke call. 

Here is the only call to the class:

Call

$model = new UserNew( new IUniversals() , new IDatabase(), new IText(), new IMessage() ); 
echo $model-&gt;invoke();


Class

class MUserNew extends MUser // set mysql defaults
{
    private $universal_object;
    private $text_object;
    private $message_object;
    private $input_fields = array( 'name', 'email', 'pass' );   

    public function __construct( $universal_object, $text_object, $message_object  )
    {
        parent::__construct();
        $this-&gt;universal_object = $universal_object;
        $this-&gt;text_object = $text_object;
        $this-&gt;message_object = $message_object;
    }
    public function invoke()
    {
        $not_validated = $this-&gt;checkInput();
        if( $this-&gt;universal_object-&gt;get( 'load' ) &amp;&amp; ( $not_validated !== true ) )
        {
            return $not_validated;
        }
        else
        {
            $email_is_unique = $this-&gt;checkEmail();
            if( ( $email_is_unique === true ) )
            {
                return $this-&gt;message_object-&gt;get( 'PASS' ) . $this-&gt;insertRecord() ;
            }
            else
            {
                return $email_is_unique;
            }
        }
    }
    private function checkInput()
    {
        if( !$this-&gt;text_object-&gt;checkEmpty() )
        {
            return $this-&gt;text_object-&gt;get( 'empty' );
        }
        foreach( $this-&gt;input_fields AS $pattern ) 
        {
            if( !$this-&gt;text_object-&gt;checkPattern( $pattern ) ) 
            {
                return $this-&gt;message_object-&gt;get( $pattern );
            }
        }
        return true;
    }
    private function checkEmail()
    {
        if( $this-&gt;database_object-&gt;_pdoQuery( 'single', 'signup_check', array($this-&gt;text_object-&gt;get('email') ) ) )
        {
            return $this-&gt;$message_object-&gt;get( 'taken' );
        }
        else
        {
            return true;
        }
    }
    private function insertRecord()
    {
        srand( time() );  
        $hash = crypt( $this-&gt;text_object-&gt;get( 'pass' ), substr( strval( rand() ), -2 ) );
        $this-&gt;text_object-&gt;set('pass', $hash );
        $this-&gt;database_object-&gt;_pdoQuery( 'single', 'signup_insert', array( '', $this-&gt;text_object-&gt;get('name'), $this-&gt;text_object-&gt;get('email'), $this-&gt;text_object-&gt;get('pass'), 0, 0 ) );
        $this-&gt;database_object-&gt;_pdoQuery( 'none', 'bookmark_insert', array($result['id'], 'Facebook', 'http://www.facebook.com', 'facebook.com', 'social', 'http://static.ak.fbcdn.net/rsrc.php/yi/r/q9U99v3_saj.ico'));                
        return $hash;
    }


}
Where do I begin?

Simplest first. Make sure you assign your constructor a state (public, private, or protected). Most likely public.

Now... Where are all these extra properties coming from? $ISharedObject is not even remotely similar to anything else, so it isn't a typo. And its not defined as a class property, so I can't even be sure this is supposed to be here. The class you provide does not extend a parent class, so it isn't from there. It just appeared in invoke() out of no where. The method it uses suggests that it is most likely a $MessageObject but I don't know.

It looks like you've either copy-pasted this all together, or had a collaboration with someone else and you've crossed your naming schemes. $MessageObject and $TextObject looks like they should be $message_object and $text_object respectively. They should be renamed as such or vice-versa. It is probably easier to rename where they are defined, less to change, but up to you.

You have a $not_validated and $validated variable, of which only the first was defined.

If checkEmail() only ever returns a boolean, like its name suggests, then there is no need for absolute equality operators "===". Just if( $email_is_unique ). If it returns something other than a boolean, then it is doing too much and needs to be separated into multiple functions.

Arrays and loops are your best friend for repititive code.

$patterns = array(
    'name',
    'email',
    'pass',
);

foreach( $patterns AS $pattern ) {
    if( !$this-&gt;TextObject-&gt;checkPattern( $pattern ) ) {
        return $this-&gt;MessageObject-&gt;get( $pattern );
    }
}
return true;


Change these first few things and I'll take another look, but right now this is very confusing.

UPDATE

"This has irked me for a long time...code that is DRY ( Don't Repeat Yourself )...is less efficient then code that has some repetition. Dry is a good concept unless taken to extreme...as far as looping goes...either way is fine I think....I'll add the loop in as a matter of preference even though a tad bit less efficient."

How do you figure this is less efficient?

$patterns = array( 'name', 'email', 'pass' );   
foreach( $patterns AS $pattern ) 
{
    if( !$this-&gt;$text_object-&gt;checkPattern( $pattern ) ) 
    {
        return $this-&gt;$message_object-&gt;get( $pattern );
    }
}


Than this?

if( !$this-&gt;$text_object-&gt;checkPattern( 'name' ) ) 
{
    return $this-&gt;$message_object-&gt;get( 'name' );
}
if( !$this-&gt;$text_object-&gt;checkPattern( 'email' ) ) 
{
    return $this-&gt;$message_object-&gt;get( 'email' );
}
if( !$this-&gt;$text_object-&gt;checkPattern( 'pass' ) ) 
{
    return $this-&gt;$message_object-&gt;get( 'pass' );
}


The first reduces the amount of code written, which in turn reduces the amount of times you can make mistakes, which in turn reduces the amount of lines you'll have to wade through should you ever need to debug it. It also automates similar tasks for any parameters you wish to throw at it so that if that task should ever need to change, you'll only ever have to do so once. Or should you ever wish to add to it, you only need to add a parameter to an array. Where did you hear that DRY is inefficient? I admit abusing it could get ridiculous, but you have to go out of your way to accomplish that.

Anyways, here's what I have for your update.

You still have that issue with variables and properties appearing out of thin air. $validated I'm assuming should be $not_validated. Though I, personally, would switch that around. I like imagining my variables like this to be asking a question "validated?" and not "telling" you its state. But thats a preference. $TextObject should probably be $text_object.

Another thing I just noticed. You are declaring your properties like so: $this-&gt;$text_object; When they should be declared like so: $this-&gt;text_object; The first is called a variable variable. It states that whatever the value of $text_object is will be declared as the name of a new property. First of all, these are cosidered bad form, mostly because they are impossible to track and make your code unuseable by anyone but you. Not really, but pretty damn close, not even IDE's can track these. Here it is explained in code, hopefully more clear.

$a = 'apple';
$b = 'banana';
$this-&gt;a = $b;
$this-&gt;$a = 'orange';
$$a = 'tangerine';

echo $a;//apple
echo $b;//banana
echo $this-&gt;a;//banana
echo $this-&gt;apple;//orange
echo $apple;//tangerine
//$this-&gt;apple and $apple just magically appeared, this is because they were set from the value of $a.


You have a couple of really long statements that could be made more legible. There are a few ways you can do this. The simplest is to bring the parameters out of the method call and convert them to variables in the local scope. This is pretty common and helps clean up code quite a bit.

$email = array( $this-&gt;TextObject-&gt;get('email') );
if( $this-&gt;$database_object-&gt;_pdoQuery( 'single', 'signup_check', $email ) )


Another way, usually used in conjunction with the previous, is to use PHP's helpful nature to your advantage. PHP does not care about whitespace, so you can drop long statements like this to new lines and indent to your hearts content.

$this-&gt;$database_object-&gt;_pdoQuery(
    'single',
    'signup_insert',
    array(
        '',
        $this-&gt;TextObject-&gt;get('name'),
        $this-&gt;TextObject-&gt;get('email'),
        $this-&gt;TextObject-&gt;get('pass'),
        0,
        0
    )
);
//OR
$name = $this-&gt;TextObject-&gt;get('name');
$email = $this-&gt;TextObject-&gt;get('email');
$pass = $this-&gt;TextObject-&gt;get('pass');
$array = array(
    '',
    $name,
    $email,
    $pass,
    0,
    0
);
$this-&gt;$database_object-&gt;_pdoQuery(
    'single',
    'signup_insert',
    $array
);


Last thing I want to mention is magic numbers. Those are numbers that appear out of thin air and could mean anything. Much like those variable variables I mentioned earlier, they are almost impossible to track down. To you, as the author, you probably know what these are at a glance. But to someone reading your code for the first time, they will not have a clue. This could even be you in a few months after you've started working on other projects. Take a look at the code above. Those zeroes "0" and empty strings '' don't mean anything. They just exist. They are magic. Declare them and set them as variables so people know what they do.