From 19fb3b418f43fca6df4a3fcd47a4dd846b0a87d1 Mon Sep 17 00:00:00 2001 From: freek Date: Sat, 1 Dec 2018 11:52:02 +0100 Subject: [PATCH] simplify newing up the channel --- src/WebSockets/Channels/ChannelManager.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/WebSockets/Channels/ChannelManager.php b/src/WebSockets/Channels/ChannelManager.php index 7bcf4d5..2e4e860 100644 --- a/src/WebSockets/Channels/ChannelManager.php +++ b/src/WebSockets/Channels/ChannelManager.php @@ -16,8 +16,9 @@ class ChannelManager public function findOrCreate(string $appId, string $channelId): Channel { if (!isset($this->channels[$appId][$channelId])) { - $this->channels[$appId][$channelId] = (new ReflectionClass($this->detectChannelClass($channelId))) - ->newInstance($channelId); + $channelClass = $this->determineChannelClass($channelId); + + $this->channels[$appId][$channelId] = new $channelClass($channelId); } return $this->channels[$appId][$channelId]; @@ -28,7 +29,7 @@ class ChannelManager return $this->channels[$appId][$channelId] ?? null; } - protected function detectChannelClass(string $channelId): string + protected function determineChannelClass(string $channelId): string { if (starts_with($channelId, 'private-')) { return PrivateChannel::class;