simplify newing up the channel

This commit is contained in:
freek 2018-12-01 11:52:02 +01:00
parent 803864c8cd
commit 19fb3b418f
1 changed files with 4 additions and 3 deletions

View File

@ -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;