2021-03-03 18:35:04 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Annotation\Model;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use Annotation\Attribute;
|
|
|
|
|
use Database\ActiveRecord;
|
2021-05-03 03:48:52 +08:00
|
|
|
use Snowflake\Snowflake;
|
2021-03-03 18:35:04 +08:00
|
|
|
|
|
|
|
|
#[\Attribute(\Attribute::TARGET_METHOD)] class Set extends Attribute
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set constructor.
|
|
|
|
|
* @param string $name
|
|
|
|
|
*/
|
|
|
|
|
public function __construct(public string $name)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2021-05-03 03:48:52 +08:00
|
|
|
/**
|
|
|
|
|
* @param mixed $class
|
|
|
|
|
* @param mixed|null $method
|
|
|
|
|
* @return bool
|
|
|
|
|
* @throws \Exception
|
|
|
|
|
*/
|
|
|
|
|
public function execute(mixed $class, mixed $method = null): bool
|
2021-03-03 18:35:04 +08:00
|
|
|
{
|
2021-05-03 03:48:52 +08:00
|
|
|
$annotation = Snowflake::getAnnotation();
|
|
|
|
|
$annotation->addSets($class::class, $this->name, $method);
|
|
|
|
|
return true;
|
2021-03-03 18:35:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|