Files
kiri-core/Annotation/Port.php
T

41 lines
562 B
PHP
Raw Normal View History

2021-03-08 13:41:46 +08:00
<?php
namespace Annotation;
2021-04-19 14:28:50 +08:00
use Exception;
use Snowflake\Snowflake;
/**
* Class Port
* @package Annotation
*/
2021-03-08 13:41:46 +08:00
#[\Attribute(\Attribute::TARGET_METHOD)] class Port extends Attribute
{
/**
* Port constructor.
* @param int $port
*/
public function __construct(public int $port)
{
}
/**
* @param array $handler
* @return mixed
2021-04-19 14:28:50 +08:00
* @throws Exception
2021-03-08 13:41:46 +08:00
*/
public function execute(array $handler): mixed
{
2021-04-19 14:28:50 +08:00
$router = Snowflake::app()->getRouter();
$router->addPortListen($this->port, $handler);
return parent::execute($handler);
2021-03-08 13:41:46 +08:00
}
}