container->get($serviceName); if ($class === null) { throw new \LogicException('no class found for service '.$serviceName, 400); } if (!method_exists($class, $method)) { throw new \LogicException('method_not_exist', 400); } return $class->{$method}(...$parameters); } /** * Appelle une fonction avec ses paramètres depuis le nom d'une classe. * * @param mixed[] $parameters * @param mixed[] $constructorParameters * * @throws \ReflectionException */ public function dynamicInvokeClassWithArgsAndMethod(string $className, string $methodName, array $parameters = [], array $constructorParameters = []): mixed { $reflection = new \ReflectionClass($className); $method = $reflection->getMethod($methodName); if ($method->isStatic()) { return $method->invoke(null, ...$parameters); } return $method->invoke(new $className(...$constructorParameters), ...$parameters); } }