OOP in php, object structure, handling

A

Anonymous

Guest
Hello,
I have the following object handling from a tutorial and I don't understand why the object is passed to another variable and then the other variable is then used as the referent? (by the way I get an error message when I do it like that)

Code:
if(Input::exists()) {
 if(Token::check(Input::get('token'))) {
    

    $validate = new Validate();
    $validation = $validate->check($_POST,array('name'=>array(
        'required' => true,
        'min' => 2,
        'max' => 50

    )
));

    if($validation->passed()) {

        //update
    } else {

        foreach($validation->errors() as $error) {

            echo $error, '<br/>';
        }
    }
 }

Why is $validation used here?
I just use $validate then but it would intersting if there is something behind the construction?

Thanks, iago
 
My best guess is:

The contructor of Validate class calls a static function that probably has the same naming convention

The object returned by $validate->check will make more sense if named validation
 
That will probably will lead to polymorphism which could lead to problems. I think there is a better way in writing that.
 
Back
Top