credits
This commit is contained in:
@@ -5,6 +5,11 @@ class Route
|
||||
{
|
||||
private array $methods = [];
|
||||
|
||||
/**
|
||||
* @param string|null $method
|
||||
* @param $controller
|
||||
* @author Johannes Kantz
|
||||
*/
|
||||
public function __construct(string $method = null, $controller = null)
|
||||
{
|
||||
if ($method != null && $controller != null) {
|
||||
@@ -12,36 +17,66 @@ class Route
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $controller
|
||||
* @return $this
|
||||
* @author Johannes Kantz
|
||||
*/
|
||||
public function get($controller)
|
||||
{
|
||||
$this->methods["GET"] = $controller;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $controller
|
||||
* @return $this
|
||||
* @author Johannes Kantz
|
||||
*/
|
||||
public function post($controller)
|
||||
{
|
||||
$this->methods["POST"] = $controller;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $controller
|
||||
* @return $this
|
||||
* @author Johannes Kantz
|
||||
*/
|
||||
public function put($controller)
|
||||
{
|
||||
$this->methods["PUT"] = $controller;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $controller
|
||||
* @return $this
|
||||
* @author Johannes Kantz
|
||||
*/
|
||||
public function delete($controller)
|
||||
{
|
||||
$this->methods["DELETE"] = $controller;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $controller
|
||||
* @return $this
|
||||
* @author Johannes Kantz
|
||||
*/
|
||||
public function all($controller)
|
||||
{
|
||||
$this->methods["ALL"] = $controller;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $method
|
||||
* @return mixed
|
||||
* @author Johannes Kantz
|
||||
*/
|
||||
public function getController(string $method)
|
||||
{
|
||||
return $this->methods[$method] ?? $this->methods["ALL"];
|
||||
|
Reference in New Issue
Block a user