From: Roland Häder Date: Tue, 12 Feb 2013 05:42:05 +0000 (+0000) Subject: Encapsulated this code (as it is a better style) X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=26986688bf700b3b7fee6deb559d51b72f19ff09;p=hub.git Encapsulated this code (as it is a better style) --- diff --git a/application/hub/interfaces/helper/nodes/class_NodeHelper.php b/application/hub/interfaces/helper/nodes/class_NodeHelper.php index 1e1dd0a16..280fd9d8c 100644 --- a/application/hub/interfaces/helper/nodes/class_NodeHelper.php +++ b/application/hub/interfaces/helper/nodes/class_NodeHelper.php @@ -115,6 +115,13 @@ interface NodeHelper extends Helper, AddableCriteria { */ function getAddressPort (); + /** + * "Getter for address:port array + * + * @return $addressPortArray An array address:port combination for this node + */ + function getAddressPortArray (); + /** * Updates/refreshes node data (e.g. state). * diff --git a/application/hub/main/database/wrapper/node/class_NodeDistributedHashTableDatabaseWrapper.php b/application/hub/main/database/wrapper/node/class_NodeDistributedHashTableDatabaseWrapper.php index dbf3c66c3..f061f169d 100644 --- a/application/hub/main/database/wrapper/node/class_NodeDistributedHashTableDatabaseWrapper.php +++ b/application/hub/main/database/wrapper/node/class_NodeDistributedHashTableDatabaseWrapper.php @@ -79,7 +79,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseDatabaseWrapper implem $dataSetInstance->setUniqueKey(self::DB_COLUMN_NODE_ID); // Get ip:port combination and "explode" it - $ipPort = explode(':' . $nodeInstance->getAddressPort()); + $ipPort = $nodeInstance->getAddressPortArray(); // Make sure both is valid assert(($ipPort[0] !== 'invalid') && ($ipPort[1] !== 'invalid')); @@ -112,7 +112,7 @@ class NodeDistributedHashTableDatabaseWrapper extends BaseDatabaseWrapper implem $nodeInstance = Registry::getRegistry()->getInstance('node'); // Get ip:port combination and "explode" it - $ipPort = explode(':' . $nodeInstance->getAddressPort()); + $ipPort = $nodeInstance->getAddressPortArray()); // Make sure both is valid assert(($ipPort[0] !== 'invalid') && ($ipPort[1] !== 'invalid')); diff --git a/application/hub/main/nodes/class_BaseHubNode.php b/application/hub/main/nodes/class_BaseHubNode.php index 5d9d9848c..c197b489f 100644 --- a/application/hub/main/nodes/class_BaseHubNode.php +++ b/application/hub/main/nodes/class_BaseHubNode.php @@ -708,6 +708,19 @@ class BaseHubNode extends BaseHubSystem implements Updateable, AddableCriteria { return $addressPort; } + /** + * "Getter" for address:port array + * + * @return $addressPortArray An array of a address:port combination for this node + */ + public final function getAddressPort () { + // Get IP and port + $addressPortArray = explode(':', $this->getAddressPort(); + + // Return it + return $addressPortArray; + } + /** * Updates/refreshes node data (e.g. status). *