X-Git-Url: https://git.mxchange.org/?p=core.git;a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Ffactories%2Fclient%2Fclass_ClientFactory.php;fp=inc%2Fclasses%2Fmain%2Ffactories%2Fclient%2Fclass_ClientFactory.php;h=597d6be7317be5a4e366688a6a6ec5c9e68b6289;hp=880f5cec371b6378d1560b7d3a891d7da74d72c0;hb=69889e146208ca17b64f3f2f2254e8a0ba9efce6;hpb=4253d604970e9db0d64c2cda0aeec0c6531bbb62 diff --git a/inc/classes/main/factories/client/class_ClientFactory.php b/inc/classes/main/factories/client/class_ClientFactory.php index 880f5cec..597d6be7 100644 --- a/inc/classes/main/factories/client/class_ClientFactory.php +++ b/inc/classes/main/factories/client/class_ClientFactory.php @@ -36,26 +36,16 @@ class ClientFactory extends ObjectFactory { * Creates a client object for given protocol. This method uses the * registry pattern to cache those instances. * - * @param $protocol Protocol to create a client object for (e.g. 'http' for a HTTP/1.1 client) + * @param $protocolInstance An instance of a ProtocolHandler class to create a client object for (e.g. 'http' for a HTTP/1.1 client) * @param $socketResource A valid socket resource (optional) * @return $clientInstance An instance of the requested client - * @throws EmptyVariableException If a variable is empty unexpectly */ - public static final function createClientByProtokol ($protocol, $socketResource = FALSE) { - // Is the class name valid and is the class there? - if (empty($protocol)) { - // Get an instance of this factory - $factoryInstance = new ClientFactory(); - - // Throw an exception here - throw new EmptyVariableException(array($factoryInstance, 'protocol'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING); - } // END - if - + public static final function createClientByProtocolInstance (ProtocolHandler $protocolInstance, $socketResource = FALSE) { // Default is NULL (to initialize variable) $clientInstance = NULL; // Generate registry key - $registryKey = $protocol . '_client'; + $registryKey = strtolower($protocolInstance->getProtocolName()) . '_client'; // Is the key already in registry? if (Registry::getRegistry()->instanceExists($registryKey)) {