diff --git a/src/ExceptionNotifyManager.php b/src/ExceptionNotifyManager.php index f85ab48..865e46d 100644 --- a/src/ExceptionNotifyManager.php +++ b/src/ExceptionNotifyManager.php @@ -162,6 +162,27 @@ protected function attempt(string $key, int $maxAttempts, int $decaySeconds = 60 }); } + protected function createDriver($driver) + { + if (isset($this->customCreators[$driver])) { + return $this->callCustomCreator($driver); + } + + $config = $this->config->get("exception-notify.channels.$driver"); + + $studlyName = Str::studly($config['driver'] ?? $driver); + + if (method_exists($this, $method = "create{$studlyName}Driver")) { + return $this->{$method}($config); + } + + if (class_exists($class = "Guanguans\\LaravelExceptionNotify\\Channels\\{$studlyName}Channel")) { + return new $class($config); + } + + throw new \InvalidArgumentException("Driver [$driver] not supported."); + } + protected function createBarkDriver(): BarkChannel { return new BarkChannel(