/** * This function routes all requests to the validation methods. * * If validation method does not exist false will be returned. * * Optional elements will be checked before executing the validation callback. * The following values are considered as empty: false, null and an empty string or array. * * The arguments array has to be in the following order: * The First argument should be the optional state, the second state the value followed by the * arguments for the calles function. * * @see empty() * @param string Function name * @param array Arguments for the function */ public static function __callStatic($name, $arguments) { self::$errors = array(); if ($name[0] == '_') { $name = substr($name, 1); } // Use Late static binding because __CLASS__ would contain AbstractValidator if (method_exists(get_called_class(), $name) == true) { // Optional check if ($arguments[1] == true && ($arguments[0] === false || $arguments[0] === null || $arguments[0] === '' || $arguments[0] === array())) { return true; } return call_user_func_array("static::{$name}", $arguments); } else { return false; } }