getDefaultDriver(); return $this->translates[$name] ??= $this->resolve($name); } public function getDefaultDriver(): string { return $this->app['config']['translate.default']; } public function setDefaultDriver(string $name): void { $this->app['config']['translate.default'] = $name; } /** * Resolve the given translate service. * * @throws InvalidArgumentException */ public function resolve(string $name): Translate { $config = $this->getConfig($name); if (\is_null($config)) { throw new InvalidArgumentException("Translate service [{$name}] is not defined."); } return $config['driver']::init($this->app, $config['config']); } /** * Disconnect the given driver and remove from local cache. */ public function purge(?string $name = null): void { $name ??= $this->getDefaultDriver(); unset($this->translates[$name]); } /** * Dynamically call the default driver instance. */ public function __call(string $method, mixed $parameters): mixed { return $this->service()->$method(...$parameters); } private function getConfig(string $name): ?array { return $this->app['config']["translate.services.{$name}"] ?? null; } }