Files
kiri-core/Annotation/Route/Interceptor.php
T

33 lines
567 B
PHP
Raw Normal View History

2020-12-16 10:38:03 +08:00
<?php
namespace Annotation\Route;
2020-12-16 15:20:51 +08:00
use Snowflake\Snowflake;
2020-12-16 10:38:03 +08:00
/**
* Class Interceptor
* @package Annotation\Route
*/
#[\Attribute(\Attribute::TARGET_METHOD)] class Interceptor
{
/**
* Interceptor constructor.
* @param string|array $interceptor
2020-12-16 15:20:51 +08:00
* @throws
2020-12-16 10:38:03 +08:00
*/
public function __construct(public string|array $interceptor)
{
2020-12-16 15:20:51 +08:00
if (is_string($this->interceptor)) {
$this->interceptor = [$this->interceptor];
}
foreach ($this->interceptor as $key => $item) {
2020-12-16 15:37:23 +08:00
$this->interceptor[$key] = [Snowflake::createObject($item), 'Interceptor'];
2020-12-16 15:20:51 +08:00
}
2020-12-16 10:38:03 +08:00
}
}