new \Tamer\Protocols\Gearman\Client($username, $password), ProtocolType::RabbitMQ => new \Tamer\Protocols\RabbitMq\Client($username, $password), default => throw new InvalidArgumentException('Invalid protocol type'), }; } /** * @param string $protocol * @param string|null $username * @param string|null $password * @return WorkerProtocolInterface */ public static function createWorker(string $protocol, ?string $username=null, ?string $password=null): WorkerProtocolInterface { /** @noinspection PhpFullyQualifiedNameUsageInspection */ return match (strtolower($protocol)) { ProtocolType::Gearman => new \Tamer\Protocols\Gearman\Worker($username, $password), ProtocolType::RabbitMQ => new \Tamer\Protocols\RabbitMq\Worker($username, $password), default => throw new InvalidArgumentException('Invalid protocol type'), }; } }