]> git.mxchange.org Git - hub.git/commitdiff
Encapsulated this code (as it is a better style)
authorRoland Häder <roland@mxchange.org>
Tue, 12 Feb 2013 05:42:05 +0000 (05:42 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 12 Feb 2013 05:42:05 +0000 (05:42 +0000)
application/hub/interfaces/helper/nodes/class_NodeHelper.php
application/hub/main/database/wrapper/node/class_NodeDistributedHashTableDatabaseWrapper.php
application/hub/main/nodes/class_BaseHubNode.php

index 1e1dd0a16ea3c28994a4913fc9d0df5b6ea696f6..280fd9d8c42528e1caa689a482ec7c5fad403814 100644 (file)
@@ -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).
         *
index dbf3c66c3075d639e82b25f575432afddb0295b3..f061f169d48f19e40081f340b298dda82765231f 100644 (file)
@@ -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'));
index 5d9d9848c194afcbf13409a874b0c1c514938a8f..c197b489fa4f1b7e65eae1c08ef58d8b59e807a0 100644 (file)
@@ -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).
         *