notFound($handler, $params); } return $this->invoke($handler, $params, $aopName); } /** * @param $handler * @param $params * @param $aopName * @return mixed * @throws ReflectionException * @throws NotFindClassException * @throws Exception */ private function invoke($handler, $params, $aopName): mixed { $reflect = Snowflake::getDi()->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 $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); } }