container->get($serviceName); //verif méthode exist if(method_exists($class, $method)) return $class->{$method}(...$parameters); throw new \LogicException("method_not_exist", 400); } /** * Appel une fonction avec ses paramètres depuis le nom d'une classe * @param string $serviceName * @param string $method * @param array $parameters * @return mixed * @throws \ReflectionException */ public function dynamicInvokeClassWithArgsAndMethod(string $className, string $method, array $parameters = []): mixed { $reflection = new \ReflectionClass($className); $method = $reflection->getMethod($method); if($method->isStatic()){ return $method->invoke(null, $parameters); }else{ return $method->invoke($reflection, $parameters); } } }