Files
kiri-router/src/Annotate/Get.php
T

42 lines
823 B
PHP
Raw Normal View History

2023-04-15 23:29:27 +08:00
<?php
2023-04-16 01:24:30 +08:00
declare(strict_types=1);
2023-04-15 23:29:27 +08:00
2023-04-16 20:36:47 +08:00
namespace Kiri\Router\Annotate;
2023-04-15 23:29:27 +08:00
2023-04-15 23:31:16 +08:00
use Exception;
2023-04-16 01:24:30 +08:00
use Kiri\Router\Constrict\RequestMethod;
2023-04-16 23:08:57 +08:00
use Kiri\Router\Interface\InjectRouteInterface;
2023-04-15 23:31:16 +08:00
use Kiri\Router\Router;
use ReflectionException;
2023-04-15 23:29:27 +08:00
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
class Get extends AbstractRequestMethod implements InjectRouteInterface
{
2023-04-16 21:00:58 +08:00
/**
* @param string $path
*/
public function __construct(readonly public string $path)
{
}
2023-04-15 23:29:27 +08:00
/**
* @param object $class
* @param string $method
* @return void
2023-04-15 23:31:16 +08:00
* @throws ReflectionException
* @throws Exception
* @throws ReflectionException
2023-04-15 23:29:27 +08:00
*/
public function dispatch(object $class, string $method): void
{
// TODO: Implement dispatch() method.
Router::addRoute(RequestMethod::REQUEST_GET, $this->path, [$class, $method]);
}
}