versions as $version) { if ($version->isProtocol($request)) { return $version; } } throw new \InvalidArgumentException("Version not found"); } /** * @param \Guzzle\Http\Message\RequestInterface * @return bool */ public function isVersionEnabled(RequestInterface $request) { foreach ($this->versions as $version) { if ($version->isProtocol($request)) { return true; } } return false; } /** * Enable support for a specific version of the WebSocket protocol * @param \Ratchet\WebSocket\Version\VersionInterface $version * @return VersionManager */ public function enableVersion(VersionInterface $version) { $this->versions[$version->getVersionNumber()] = $version; if (empty($this->versionString)) { $this->versionString = (string)$version->getVersionNumber(); } else { $this->versionString .= ", {$version->getVersionNumber()}"; } return $this; } /** * Disable support for a specific WebSocket protocol version * @param int $versionId The version ID to un-support * @return VersionManager */ public function disableVersion($versionId) { unset($this->versions[$versionId]); $this->versionString = implode(',', array_keys($this->versions)); return $this; } /** * Get a string of version numbers supported (comma delimited) * @return string */ public function getSupportedVersionString() { return $this->versionString; } }