diff --git a/src/Service/EventServiceProvider.php b/src/Service/EventServiceProvider.php index da302aa..a85109d 100644 --- a/src/Service/EventServiceProvider.php +++ b/src/Service/EventServiceProvider.php @@ -24,14 +24,10 @@ class EventServiceProvider implements ServiceProviderInterface */ public function register(Pay $pay): void { - $service = function () use ($pay) { - $event = $pay::make(EventDispatcher::class); + $event = $pay::make(EventDispatcher::class); - $event->addSubscriber(new KernelLogSubscriber()); + $event->addSubscriber(new KernelLogSubscriber()); - return $event; - }; - - $pay::set(EventDispatcherInterface::class, $service); + $pay::set(EventDispatcherInterface::class, $event); } } diff --git a/src/Service/LoggerServiceProvider.php b/src/Service/LoggerServiceProvider.php index ea625b1..99872a0 100644 --- a/src/Service/LoggerServiceProvider.php +++ b/src/Service/LoggerServiceProvider.php @@ -28,43 +28,39 @@ class LoggerServiceProvider implements ServiceProviderInterface /* @var ConfigInterface $config */ $config = Pay::get(ConfigInterface::class); - $service = function () use ($config) { - $logger = new class($config) extends Logger { - /** - * @var ConfigInterface - */ - private $conf; + $logger = new class($config) extends Logger { + /** + * @var ConfigInterface + */ + private $conf; - /** - * Bootstrap. - */ - public function __construct(Config $config) - { - $this->conf = $config; + /** + * Bootstrap. + */ + public function __construct(Config $config) + { + $this->conf = $config; + } + + /** + * __call. + * + * @author yansongda + * + * @throws \Exception + */ + public function __call(string $method, array $args): void + { + if (false === $this->conf->get('log.enable', true)) { + return; } - /** - * __call. - * - * @author yansongda - * - * @throws \Exception - */ - public function __call(string $method, array $args): void - { - if (false === $this->conf->get('log.enable', true)) { - return; - } - - parent::__call($method, $args); - } - }; - - $logger->setConfig($config->get('log')); - - return $logger; + parent::__call($method, $args); + } }; - $pay::set(LoggerInterface::class, $service); + $logger->setConfig($config->get('log')); + + $pay::set(LoggerInterface::class, $logger); } }