Skip to main content
1 of 2
mseancole
  • 6.2k
  • 1
  • 16
  • 27

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->TextObject->checkPattern( $pattern ) ) {
        return $this->MessageObject->get( $pattern );
    }
}
return true;

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

mseancole
  • 6.2k
  • 1
  • 16
  • 27