From 706eaeda4153de130b8530713f00772df7146458 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov <38059171+askvortsov1@users.noreply.github.com> Date: Mon, 22 Mar 2021 14:00:36 -0400 Subject: [PATCH] Use anonymous class for FakeApp (#2725) It's a better implementation than declaring a second class in the same file, which can confuse IDEs. Furthermore, FakeApp shouldn't be used outside this file. --- src/Console/Schedule.php | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/src/Console/Schedule.php b/src/Console/Schedule.php index 33d223960..6deba8eb0 100644 --- a/src/Console/Schedule.php +++ b/src/Console/Schedule.php @@ -17,24 +17,21 @@ class Schedule extends LaravelSchedule { public function dueEvents($container) { - return (new Collection($this->events))->filter->isDue(new FakeApp($container)); - } -} - -class FakeApp -{ - public function __construct($container) - { - $this->config = $container->make(Config::class); - } - - public function isDownForMaintenance() - { - return $this->config->inMaintenanceMode(); - } - - public function environment() - { - return ''; + return (new Collection($this->events))->filter->isDue(new class($container) { + public function __construct($container) + { + $this->config = $container->make(Config::class); + } + + public function isDownForMaintenance() + { + return $this->config->inMaintenanceMode(); + } + + public function environment() + { + return ''; + } + }); } }