I don't think a "router" itself does enough on its own to warrant a PDO style class. I mean, my router class looks like this:
PHP Code:
interface RouterRule {
public function find(array $route);
}
class Router {
private $rules = array();
public function addRule(RouterRule $rule, $highPriority = false) {
if ($highPriority) array_unshift($this->rules, $rule);
else $this->rules[] = $rule;
}
public function getRoute(array $route) {
foreach ($this->rules as $rule) {
if ($found = $rule->find($route)) return $found;
}
throw new Exception('No matching route found');
}
}
All the framework (or even application) specific stuff is handled by rules. And these aren't going to be repeatable.... I just don't see how something as trivial as the generic router class is complex enough to need standardisation.
Bookmarks