2020-12-16 10:38:03 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Annotation\Route;
|
|
|
|
|
|
|
|
|
|
|
2021-03-03 18:35:04 +08:00
|
|
|
use Annotation\Attribute;
|
2020-12-16 15:20:51 +08:00
|
|
|
use Snowflake\Snowflake;
|
|
|
|
|
|
2020-12-16 10:38:03 +08:00
|
|
|
/**
|
|
|
|
|
* Class Limits
|
|
|
|
|
* @package Annotation\Route
|
|
|
|
|
*/
|
2021-03-03 18:35:04 +08:00
|
|
|
#[\Attribute(\Attribute::TARGET_METHOD)] class Limits extends Attribute
|
2020-12-16 10:38:03 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Limits constructor.
|
|
|
|
|
* @param string|array $limits
|
2020-12-16 15:20:51 +08:00
|
|
|
* @throws
|
2020-12-16 10:38:03 +08:00
|
|
|
*/
|
2021-03-03 18:35:04 +08:00
|
|
|
public function __construct(public string|array $limits)
|
2020-12-16 10:38:03 +08:00
|
|
|
{
|
2021-02-23 14:45:50 +08:00
|
|
|
if (is_string($this->limits)) {
|
2021-02-23 14:54:47 +08:00
|
|
|
$this->limits = [$this->limits];
|
2021-02-23 14:45:50 +08:00
|
|
|
}
|
2021-03-03 18:35:04 +08:00
|
|
|
|
|
|
|
|
foreach ($this->limits as $key => $value) {
|
|
|
|
|
$sn = Snowflake::createObject($value);
|
|
|
|
|
|
|
|
|
|
if (!($sn instanceof \HttpServer\IInterface\Limits)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->limits[$key] = [$sn, 'next'];
|
|
|
|
|
}
|
2021-02-22 17:44:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-07-12 17:17:36 +08:00
|
|
|
* @param mixed $class
|
|
|
|
|
* @param mixed|null $method
|
2021-02-23 14:18:49 +08:00
|
|
|
* @return Limits
|
2021-02-22 17:44:24 +08:00
|
|
|
*/
|
2021-05-03 03:48:52 +08:00
|
|
|
public function execute(mixed $class, mixed $method = null): static
|
2021-02-22 17:44:24 +08:00
|
|
|
{
|
2021-02-23 14:16:08 +08:00
|
|
|
return $this;
|
2020-12-16 10:38:03 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|