diff --git a/src/DingTalk/Config.php b/src/DingTalk/Config.php index 81ff560..c0586e5 100644 --- a/src/DingTalk/Config.php +++ b/src/DingTalk/Config.php @@ -3,6 +3,7 @@ namespace WonderGame\EsNotify\DingTalk; use WonderGame\EsNotify\Interfaces\ConfigInterface; +use WonderGame\EsNotify\Interfaces\NotifyInterface; use EasySwoole\Spl\SplBean; class Config extends SplBean implements ConfigInterface @@ -55,8 +56,8 @@ public function getAt() return $this->at; } - public function notifyClassName() + public function getNotifyClass(): NotifyInterface { - return Notify::class; + return new Notify(); } } diff --git a/src/EsNotify.php b/src/EsNotify.php index 7d9b328..f8ae780 100644 --- a/src/EsNotify.php +++ b/src/EsNotify.php @@ -19,9 +19,7 @@ public function register(ConfigInterface $Config, string $name = 'default') throw new \Exception('EsNotify name already exists: ' . $name); } - $className = $Config->notifyClassName(); - /** @var NotifyInterface $class */ - $class = new $className(); + $class = $Config->getNotifyClass(); $class->register($Config); $this->container[$name] = $class; diff --git a/src/Interfaces/ConfigInterface.php b/src/Interfaces/ConfigInterface.php index 15c1d79..2cd1511 100644 --- a/src/Interfaces/ConfigInterface.php +++ b/src/Interfaces/ConfigInterface.php @@ -4,5 +4,5 @@ interface ConfigInterface { - public function notifyClassName(); + public function getNotifyClass(): NotifyInterface; } diff --git a/src/WeChat/Config.php b/src/WeChat/Config.php index cee6c7e..ac1404a 100644 --- a/src/WeChat/Config.php +++ b/src/WeChat/Config.php @@ -3,6 +3,7 @@ namespace WonderGame\EsNotify\WeChat; use WonderGame\EsNotify\Interfaces\ConfigInterface; +use WonderGame\EsNotify\Interfaces\NotifyInterface; use EasySwoole\Spl\SplBean; class Config extends SplBean implements ConfigInterface @@ -107,8 +108,8 @@ public function getUrl() return $this->url; } - public function notifyClassName() + public function getNotifyClass(): NotifyInterface { - return Notify::class; + return new Notify(); } }