path = new DyPath($path); } public function __invoke(Request $req, Response $res, Arguments $args){ $err = null; $ret = true; foreach($this->handles as $k => $fn){ try{ $ret = $fn($req, $res, $args, $err) !== false || $ret === false; }catch(\Exception $e){ $err = $e; $ret = false; } } return $ret; } public function __clone(){ // No cloning for now } public function __destruct(){ // Nothing to do here } public function jsonSerialize(){ return [ 'path'=>$this->path, 'dypath'=>$this->path ]; } public function __toString(){ return "[Path {$this->path}]"; } public function handle(callable $fn){ array_push($this->handles, $fn); return $this; } public function matches(string $path){ return $this->path->matches($path); } public function args(string $path){ return $this->path->args($path); } public function count(){ return count($this->handles); } } ?>