2021-08-05 14:10:52 +08:00
|
|
|
<?php
|
|
|
|
|
|
2021-08-17 16:43:50 +08:00
|
|
|
namespace Http\Route;
|
2021-08-05 14:10:52 +08:00
|
|
|
|
2021-08-11 01:04:57 +08:00
|
|
|
use Kiri\Abstracts\BaseObject;
|
2021-08-05 14:10:52 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
class HandlerProviders extends BaseObject
|
|
|
|
|
{
|
|
|
|
|
|
2021-08-28 02:08:20 +08:00
|
|
|
private static array $handlers = [];
|
2021-08-05 14:10:52 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param $path
|
|
|
|
|
* @param $method
|
|
|
|
|
* @return mixed
|
|
|
|
|
*/
|
2021-08-28 02:08:20 +08:00
|
|
|
public static function get($path, $method): mixed
|
2021-08-05 14:10:52 +08:00
|
|
|
{
|
2021-08-28 02:08:20 +08:00
|
|
|
return static::$handlers[$method][$path] ?? null;
|
2021-08-05 14:10:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param $method
|
|
|
|
|
* @param $path
|
|
|
|
|
* @param $handler
|
|
|
|
|
*/
|
2021-08-28 02:08:20 +08:00
|
|
|
public static function add($method, $path, $handler)
|
2021-08-05 14:10:52 +08:00
|
|
|
{
|
2021-08-28 02:08:20 +08:00
|
|
|
static::$handlers[$method][$path] = $handler;
|
2021-08-05 14:10:52 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|