From d8e7ac0f3fa6be9b7f4b2850026b4c9b4880a6dd Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 19 Jan 2024 10:26:47 -0600 Subject: [PATCH] formatting --- src/Contracts/ServerProvider.php | 2 +- src/Protocols/Pusher/EventDispatcher.php | 4 ++-- src/ReverbServiceProvider.php | 6 +++--- ...rviceProviderManager.php => ServerProviderManager.php} | 8 ++++---- src/Servers/Reverb/Console/Commands/StartServer.php | 3 ++- ...ReverbServiceProvider.php => ReverbServerProvider.php} | 2 +- tests/ReverbTestCase.php | 4 ++-- tests/Unit/EventTest.php | 4 ++-- 8 files changed, 17 insertions(+), 16 deletions(-) rename src/{ServerServiceProviderManager.php => ServerProviderManager.php} (74%) rename src/Servers/Reverb/{ReverbServiceProvider.php => ReverbServerProvider.php} (97%) diff --git a/src/Contracts/ServerProvider.php b/src/Contracts/ServerProvider.php index a113e0ce..7b5835d0 100644 --- a/src/Contracts/ServerProvider.php +++ b/src/Contracts/ServerProvider.php @@ -49,6 +49,6 @@ public function shouldNotPublishEvents(): bool */ public function doesNotSubscribeToEvents(): bool { - return $this->shouldNotPublishEvents(); + return ! $this->subscribesToEvents(); } } diff --git a/src/Protocols/Pusher/EventDispatcher.php b/src/Protocols/Pusher/EventDispatcher.php index c94e1a24..1dd950b7 100644 --- a/src/Protocols/Pusher/EventDispatcher.php +++ b/src/Protocols/Pusher/EventDispatcher.php @@ -7,7 +7,7 @@ use Laravel\Reverb\Contracts\Connection; use Laravel\Reverb\Protocols\Pusher\Contracts\ChannelManager; use Laravel\Reverb\Servers\Reverb\Contracts\PubSubProvider; -use Laravel\Reverb\ServerServiceProviderManager; +use Laravel\Reverb\ServerProviderManager; class EventDispatcher { @@ -16,7 +16,7 @@ class EventDispatcher */ public static function dispatch(Application $app, array $payload, ?Connection $connection = null): void { - $server = app(ServerServiceProviderManager::class); + $server = app(ServerProviderManager::class); if ($server->shouldNotPublishEvents()) { static::dispatchSynchronously($app, $payload, $connection); diff --git a/src/ReverbServiceProvider.php b/src/ReverbServiceProvider.php index b8b385f4..fb024c16 100644 --- a/src/ReverbServiceProvider.php +++ b/src/ReverbServiceProvider.php @@ -19,9 +19,9 @@ public function register(): void $this->app->instance(Logger::class, new NullLogger); - $this->app->singleton(ServerServiceProviderManager::class); + $this->app->singleton(ServerProviderManager::class); - $this->app->make(ServerServiceProviderManager::class)->register(); + $this->app->make(ServerProviderManager::class)->register(); } /** @@ -35,6 +35,6 @@ public function boot(): void ], ['reverb', 'reverb-config']); } - $this->app->make(ServerServiceProviderManager::class)->boot(); + $this->app->make(ServerProviderManager::class)->boot(); } } diff --git a/src/ServerServiceProviderManager.php b/src/ServerProviderManager.php similarity index 74% rename from src/ServerServiceProviderManager.php rename to src/ServerProviderManager.php index 6d171945..43d7f33e 100644 --- a/src/ServerServiceProviderManager.php +++ b/src/ServerProviderManager.php @@ -4,9 +4,9 @@ use Illuminate\Contracts\Foundation\Application; use Illuminate\Support\Manager; -use Laravel\Reverb\Servers\Reverb\ReverbServiceProvider; +use Laravel\Reverb\Servers\Reverb\ReverbServerProvider; -class ServerServiceProviderManager extends Manager +class ServerProviderManager extends Manager { /** * Create a new server manager instance. @@ -19,9 +19,9 @@ public function __construct(protected Application $app) /** * Creates the Reverb driver. */ - public function createReverbDriver(): ReverbServiceProvider + public function createReverbDriver(): ReverbServerProvider { - return new ReverbServiceProvider( + return new ReverbServerProvider( $this->app, $this->config->get('reverb.servers.reverb', []) ); diff --git a/src/Servers/Reverb/Console/Commands/StartServer.php b/src/Servers/Reverb/Console/Commands/StartServer.php index 3a8bfaef..c8fe4e4f 100644 --- a/src/Servers/Reverb/Console/Commands/StartServer.php +++ b/src/Servers/Reverb/Console/Commands/StartServer.php @@ -12,6 +12,7 @@ use Laravel\Reverb\Loggers\CliLogger; use Laravel\Reverb\Protocols\Pusher\Channels\ChannelConnection; use Laravel\Reverb\Protocols\Pusher\Contracts\ChannelManager; +use Laravel\Reverb\ServerProviderManager; use Laravel\Reverb\Servers\Reverb\Contracts\PubSubProvider; use Laravel\Reverb\Servers\Reverb\Factory as ServerFactory; use Laravel\Reverb\Servers\Reverb\Http\Server; @@ -55,7 +56,7 @@ public function handle(): void $server = ServerFactory::make($host, $port, loop: $loop); - if ($this->laravel->make(ServerServiceProviderManager::class)->subscribesToEvents()) { + if ($this->laravel->make(ServerProviderManager::class)->subscribesToEvents()) { $this->laravel->make(PubSubProvider::class)->connect($loop); $this->laravel->make(PubSubProvider::class)->subscribe(); } diff --git a/src/Servers/Reverb/ReverbServiceProvider.php b/src/Servers/Reverb/ReverbServerProvider.php similarity index 97% rename from src/Servers/Reverb/ReverbServiceProvider.php rename to src/Servers/Reverb/ReverbServerProvider.php index c3e3a81f..f5819444 100644 --- a/src/Servers/Reverb/ReverbServiceProvider.php +++ b/src/Servers/Reverb/ReverbServerProvider.php @@ -11,7 +11,7 @@ use Laravel\Reverb\Servers\Reverb\Publishing\RedisClientFactory; use Laravel\Reverb\Servers\Reverb\Publishing\RedisPubSubProvider; -class ReverbServiceProvider extends ServerProvider +class ReverbServerProvider extends ServerProvider { /** * Indicates whether the Reverb server should publish events. diff --git a/tests/ReverbTestCase.php b/tests/ReverbTestCase.php index b8fcef19..2dda338a 100644 --- a/tests/ReverbTestCase.php +++ b/tests/ReverbTestCase.php @@ -5,7 +5,7 @@ use Illuminate\Support\Str; use Laravel\Reverb\Servers\Reverb\Contracts\PubSubProvider; use Laravel\Reverb\Servers\Reverb\Factory; -use Laravel\Reverb\ServerServiceProviderManager; +use Laravel\Reverb\ServerProviderManager; use Ratchet\Client\WebSocket; use React\Async\SimpleFiber; use React\EventLoop\Loop; @@ -73,7 +73,7 @@ protected function defineEnvironment($app): void */ public function usingRedis(): void { - app(ServerServiceProviderManager::class)->withPublishing(); + app(ServerProviderManager::class)->withPublishing(); app(PubSubProvider::class)->connect($this->loop); app(PubSubProvider::class)->subscribe(); diff --git a/tests/Unit/EventTest.php b/tests/Unit/EventTest.php index 780a72ae..8c7a3257 100644 --- a/tests/Unit/EventTest.php +++ b/tests/Unit/EventTest.php @@ -4,11 +4,11 @@ use Laravel\Reverb\Protocols\Pusher\Contracts\ChannelConnectionManager; use Laravel\Reverb\Protocols\Pusher\EventDispatcher; use Laravel\Reverb\Servers\Reverb\Contracts\PubSubProvider; -use Laravel\Reverb\ServerServiceProviderManager; +use Laravel\Reverb\ServerProviderManager; it('can publish an event when enabled', function () { $app = app(ApplicationProvider::class)->findByKey('pusher-key'); - app(ServerServiceProviderManager::class)->withPublishing(); + app(ServerProviderManager::class)->withPublishing(); $pubSub = Mockery::mock(PubSubProvider::class); $pubSub->shouldReceive('publish')->once() ->with(['application' => serialize($app), 'payload' => ['channel' => 'test-channel']]);