/** * Allows accessing get, post, put and delete method statically. * * This method offers the convenient static entry point to the class like * * WPRouting_Route::get('hello', $callback)->... * * @param string $func The method name * @param array $args The method arguments * * @return WPRouting_Route A new instance of this class */ public static function __callStatic($func, $args) { // get defined public methods $publicMethods = array('get', 'post', 'put', 'delete', 'all'); // if not $func in defined public method throw if (!in_array($func, $publicMethods)) { throw new InvalidArgumentException("{$func} is not a defined class method", 1); } // create and set an instance of the class $instance = new self(); $instance->hook(); call_user_func_array(array($instance, "_{$func}"), $args); return $instance; }
public static function add($class, $message, $dissmissable = false, $priority = 20) { $notice = new self($class, $message, $dissmissable); $notice->hook($priority); return $notice; }