Example #1
0
 /**
  * Recurse through the Routes until a match is found.
  *
  * When called multiple times (in a loop for instance)
  * this method will return a new matching route until
  * all routes have been processed.
  *
  * Once exhausted this function returns false and the
  * internal pointer is reset so the Router can be used
  * again.
  *
  * @return bool|Proem\Routing\Route\Payload
  */
 public function route()
 {
     if ($route = $this->routes->current()) {
         $this->routes->next();
         $route->process($this->request);
         if ($route->isMatch() && $route->getPayload()->isPopulated()) {
             if ($route->hasCallback()) {
                 return $route->call($this->request);
             }
             return $route->getPayload();
         } else {
             return $this->route();
         }
     }
     $this->routes->rewind();
     return false;
 }