src/Router.php
public function addRoute($method, $route, $action, $extra = [])
	{
		$name = (isset($extra["name"])) ? $extra["name"] : $route;

		if (isset($this->rawRoutes[$name])) {
			$Route = $this->rawRoutes[$name];
		} else {
			$Route              = clone $this->Route;
			$Route->route       = $this->baseUri.$route;
			$Route->name 		= $name;
		}

		$Route->addExtra($extra);
		$methods = [];
		if ("ANY" === $method) {
			$methods["GET"]  = $action;
			$methods["POST"] =& $methods["GET"];
			$methods["PUT"]  =& $methods["GET"];

			$Route->methods = $methods;
			$Route->action = $action;

			$this->rawRoutes[$name] = $Route;
		} else {

			$arrayedMethod = (array) $method;
			$count = count($arrayedMethod);

			for ($i = 0; $i < $count; $i++) {
				if (!isset($this->allowedMethods[$arrayedMethod[$i]])) {
					throw new InvalidMethodException("Method: " . $arrayedMethod[$i] . " is not valid");
				}
				$method = $arrayedMethod[$i];
				$Route->action = $action;
				$Route->method = $method;
				$Route->name = $name;
				$this->rawRoutes[$name] = $Route;
			}
		}


		return $Route;
	}
public function addRoute($method, $route, $action, $extra = [])
	{
		$name = (isset($extra["name"])) ? $extra["name"] : $route;

		if (isset($this->rawRoutes[$name])) {
			$Route = $this->rawRoutes[$name];
		} else {
			$Route              = clone $this->Route;
			$Route->route       = $this->baseUri.$route;
			$Route->name 		= $name;
		}

		$Route->addExtra($extra);
		$methods = [];
		if ("ANY" === $method) {
			$methods["GET"]  = $action;
			$methods["POST"] =& $methods["GET"];
			$methods["PUT"]  =& $methods["GET"];

			$Route->methods = $methods;
			$Route->action = $action;

			$this->rawRoutes[$name] = $Route;
		} else {

			$arrayedMethod = (array) $method;
			$count = count($arrayedMethod);

			for ($i = 0; $i < $count; $i++) {
				if (!isset($this->allowedMethods[$arrayedMethod[$i]])) {
					throw new InvalidMethodException("Method: " . $arrayedMethod[$i] . " is not valid");
				}
				$method = $arrayedMethod[$i];
				$Route->action = $action;
				$Route->method = $method;
				$Route->name = $name;
				$this->rawRoutes[$name] = $Route;
			}
		}


		return $Route;
	}
public function addRoute ( $ method , $ route , $ action , $ extra = [ ] ) { $ name = ( isset ( $ extra [ "name" ] ) ) ? $ extra [ "name" ] : $ route ; if ( isset ( $ this -> rawRoutes [ $ name ] ) ) { $ Route = $ this -> rawRoutes [ $ name ] ; } else { $ Route = clone $ this -> Route ; $ Route -> route = $ this -> baseUri . $ route ; $ Route -> name = $ name ; } $ Route -> addExtra ( $ extra ) ; $ methods = [ ] ; if ( "ANY" === $ method ) { $ methods [ "GET" ] = $ action ; $ methods [ "POST" ] = & $ methods [ "GET" ] ; $ methods [ "PUT" ] = & $ methods [ "GET" ] ; $ Route -> methods = $ methods ; $ Route -> action = $ action ; $ this -> rawRoutes [ $ name ] = $ Route ; } else { $ arrayedMethod = ( array ) $ method ; $ count = count ( $ arrayedMethod ) ; for ( $ i = 0 ; $ i < $ count ; $ i ++ ) { if ( ! isset ( $ this -> allowedMethods [ $ arrayedMethod [ $ i ] ] ) ) { throw new InvalidMethodException ( "Method: " . $ arrayedMethod [ $ i ] . " is not valid" ) ; } $ method = $ arrayedMethod [ $ i ] ; $ Route -> action = $ action ; $ Route -> method = $ method ; $ Route -> name = $ name ; $ this -> rawRoutes [ $ name ] = $ Route ; } } return $ Route ; }
Add new route to list of available routes

@param $method
@param $route
@param $action
@throws InvalidMethodException
Add new route to list of available routes