2021-03-15 02:54:16 +08:00
|
|
|
<?php
|
|
|
|
|
|
2022-03-15 18:05:33 +08:00
|
|
|
declare(strict_types=1);
|
2021-03-15 02:54:16 +08:00
|
|
|
|
|
|
|
|
namespace ZM\Annotation\Swoole;
|
|
|
|
|
|
2022-03-20 01:53:36 +08:00
|
|
|
use Attribute;
|
|
|
|
|
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
2021-03-15 02:54:16 +08:00
|
|
|
use Doctrine\Common\Annotations\Annotation\Required;
|
|
|
|
|
use Doctrine\Common\Annotations\Annotation\Target;
|
|
|
|
|
use ZM\Annotation\AnnotationBase;
|
|
|
|
|
use ZM\Annotation\Interfaces\Rule;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class OnTask
|
|
|
|
|
* @Annotation
|
2022-03-20 01:53:36 +08:00
|
|
|
* @NamedArgumentConstructor()
|
2021-03-15 02:54:16 +08:00
|
|
|
* @Target("METHOD")
|
|
|
|
|
*/
|
2022-03-20 01:53:36 +08:00
|
|
|
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_METHOD)]
|
2021-03-15 02:54:16 +08:00
|
|
|
class OnTask extends AnnotationBase implements Rule
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* @var string
|
|
|
|
|
* @Required()
|
|
|
|
|
*/
|
|
|
|
|
public $task_name;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
2022-03-15 18:05:33 +08:00
|
|
|
public $rule = '';
|
2021-03-15 02:54:16 +08:00
|
|
|
|
2022-03-20 01:53:36 +08:00
|
|
|
public function __construct($task_name, $rule = '')
|
|
|
|
|
{
|
|
|
|
|
$this->task_name = $task_name;
|
|
|
|
|
$this->rule = $rule;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-15 02:54:16 +08:00
|
|
|
/**
|
|
|
|
|
* @return mixed
|
|
|
|
|
*/
|
2022-03-15 18:05:33 +08:00
|
|
|
public function getRule(): string
|
|
|
|
|
{
|
2021-03-15 02:54:16 +08:00
|
|
|
return $this->rule;
|
|
|
|
|
}
|
2022-03-15 18:05:33 +08:00
|
|
|
}
|