getReflect(current(static::$_aop[$aopName])); if (!$reflect->isInstantiable() || !$reflect->hasMethod('invoke')) { throw new Exception(ASPECT_ERROR . IAspect::class); } $method = $reflect->getMethod('invoke'); return $method->invokeArgs($reflect->newInstance($handler), $params); } /** * @param array $handler * @return IAspect * @throws Exception * @throws ReflectionException */ public function getAop(array $handler): IAspect { $aopName = $handler[0]::class . '::' . $handler[1]; $reflect = Snowflake::getDi()->get(current(static::$_aop[$aopName])); if (!method_exists($reflect, 'invoke')) { throw new Exception(ASPECT_ERROR . IAspect::class); } return $reflect; } /** * @param $handler * @param $params * @return mixed * @throws Exception */ private function notFound($handler, $params): mixed { if (!method_exists($handler[0], $handler[1])) { return response()->close(404); } return call_user_func($handler, ...$params); } }