X-Git-Url: https://git.mxchange.org/?p=core.git;a=blobdiff_plain;f=framework%2Fmain%2Fclasses%2Ffactories%2Fclient%2Fclass_ClientFactory.php;h=3b182f8f7135c9cb99d853fc2014744f615dde34;hp=339f076dbbc36cbc433cf1315c58ef98cfc610d7;hb=refs%2Fheads%2Fmaster;hpb=027c5659e968546a21be37e70d700c7e14cba993 diff --git a/framework/main/classes/factories/client/class_ClientFactory.php b/framework/main/classes/factories/client/class_ClientFactory.php index 339f076d..3b0e3fd4 100644 --- a/framework/main/classes/factories/client/class_ClientFactory.php +++ b/framework/main/classes/factories/client/class_ClientFactory.php @@ -6,6 +6,9 @@ namespace Org\Mxchange\CoreFramework\Factory\Client; use Org\Mxchange\CoreFramework\Factory\BaseFactory; use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory; +// Import SPL +use \Socket; + /** * An object factory for clients * @@ -44,10 +47,10 @@ class ClientFactory extends BaseFactory { * registry pattern to cache those instances. * * @param $protocolInstance An instance of a HandleableProtocol class to create a client object for (e.g. 'http' for a HTTP/1.1 client) - * @param $socketResource A valid socket resource (optional) + * @param $socketResource An instance of a Socket class (optional) * @return $clientInstance An instance of the requested client */ - public static final function createClientByProtocolInstance (HandleableProtocol $protocolInstance, $socketResource = FALSE) { + public static final function createClientByProtocolInstance (HandleableProtocol $protocolInstance, Socket $socketResource = NULL) { // Default is NULL (to initialize variable) $clientInstance = NULL; @@ -55,18 +58,18 @@ class ClientFactory extends BaseFactory { $registryKey = strtolower($protocolInstance->getProtocolName()) . '_client'; // Is the key already in registry? - if (GenericRegistry::getRegistry()->instanceExists($registryKey)) { + if (ObjectRegistry::getRegistry('factory')->instanceExists($registryKey)) { // Then use that instance - $clientInstance = GenericRegistry::getRegistry()->getInstance($registryKey); + $clientInstance = ObjectRegistry::getRegistry('factory')->getInstance($registryKey); // Set socket resource $clientInstance->setSocketResource($socketResource); } else { // Generate object instance - $clientInstance = ObjectFactory::createObjectByConfiguredName($registryKey, array($socketResource)); + $clientInstance = ObjectFactory::createObjectByConfiguredName($registryKey, [$socketResource]); // Set it in registry for later re-use - GenericRegistry::getRegistry()->addInstance($registryKey, $clientInstance); + ObjectRegistry::getRegistry('factory')->addInstance($registryKey, $clientInstance); } // Return the prepared instance