50 lines
951 B
PHP
50 lines
951 B
PHP
<?php
|
|
|
|
|
|
namespace Annotation;
|
|
|
|
|
|
use Exception;
|
|
use Snowflake\Aop;
|
|
use Snowflake\IAspect;
|
|
use Snowflake\Snowflake;
|
|
|
|
defined('ASPECT_ERROR') or define('ASPECT_ERROR', 'Aspect annotation must implement ');
|
|
|
|
/**
|
|
* Class Aspect
|
|
* @package Annotation
|
|
*/
|
|
#[\Attribute(\Attribute::TARGET_METHOD)] class Aspect extends Attribute
|
|
{
|
|
|
|
|
|
/**
|
|
* Aspect constructor.
|
|
* @param string $aspect
|
|
*/
|
|
public function __construct(public string $aspect)
|
|
{
|
|
}
|
|
|
|
|
|
/**
|
|
* @throws Exception
|
|
*/
|
|
public function execute(mixed $class, mixed $method = ''): bool
|
|
{
|
|
// TODO: Change the autogenerated stub
|
|
// if (!in_array(IAspect::class, class_implements($this->aspect))) {
|
|
// throw new Exception(ASPECT_ERROR . IAspect::class);
|
|
// }
|
|
// /** @var Aop $aop */
|
|
// $aop = Snowflake::getDi()->get(Aop::class);
|
|
//
|
|
// $aop->aop_add([$class, $method], $this->aspect);
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
}
|