src/Event.php
public static function bindClass($class, $priority = Event::PRIORITY_NORMAL) {
        $method_names = get_class_methods($class);

        // Grab an instance of the class so there is something to bind to.
        if (is_string($class)) {
            if (method_exists($class, 'instance')) {
                // TODO: Make the instance lazy load.
                $instance = call_user_func(array($class, 'instance'));
            } else {
                throw new \InvalidArgumentException('Event::bindClass(): The class for argument #1 must have an instance() method or be passed as an object.', 422);
            }
        } else {
            $instance = $class;
        }

        foreach ($method_names as $method_name) {
            if (strpos($method_name, '_') === false) {
                continue;
            }

            $parts = explode('_', strtolower($method_name));
            switch (end($parts)) {
                case 'handler':
                case 'create':
                case 'override':
                    array_pop($parts);
                    $event_name = implode('_', $parts);
                    break;
                case 'before':
                case 'after':
                default:
                    $event_name = implode('_', $parts);
                    break;
            }
            // Bind the event if we have one.
            if ($event_name) {
                static::bind($event_name, array($instance, $method_name), $priority);
            }
        }
    }
public static function bindClass($class, $priority = Event::PRIORITY_NORMAL) {
        $method_names = get_class_methods($class);

        // Grab an instance of the class so there is something to bind to.
        if (is_string($class)) {
            if (method_exists($class, 'instance')) {
                // TODO: Make the instance lazy load.
                $instance = call_user_func(array($class, 'instance'));
            } else {
                throw new \InvalidArgumentException('Event::bindClass(): The class for argument #1 must have an instance() method or be passed as an object.', 422);
            }
        } else {
            $instance = $class;
        }

        foreach ($method_names as $method_name) {
            if (strpos($method_name, '_') === false) {
                continue;
            }

            $parts = explode('_', strtolower($method_name));
            switch (end($parts)) {
                case 'handler':
                case 'create':
                case 'override':
                    array_pop($parts);
                    $event_name = implode('_', $parts);
                    break;
                case 'before':
                case 'after':
                default:
                    $event_name = implode('_', $parts);
                    break;
            }
            // Bind the event if we have one.
            if ($event_name) {
                static::bind($event_name, array($instance, $method_name), $priority);
            }
        }
    }
Bind a class' declared event handlers.

Plugin classes declare event handlers in the following way:

```
// Bind to a normal event.
public function eventname_handler($arg1, $arg2, ...) { ... }

// Add/override a method called with Event::callUserFuncArray().
public function ClassName_methodName($sender, $arg1, $arg2) { ... }
public function ClassName_methodName_create($sender, $arg1, $arg2) { ... } // deprecated

// Call the handler before or after a method called with Event::callUserFuncArray().
public function ClassName_methodName_before($sender, $arg1, $arg2) { ... }
public function ClassName_methodName_after($sender, $arg1, $arg2) { ... }
```

@param mixed $class The class name or an object instance.
@param int $priority The priority of the event.
@throws \InvalidArgumentException Throws an exception when binding to a class name with no `instance()` method.