From: Roland Häder Date: Tue, 4 Aug 2009 23:23:54 +0000 (+0000) Subject: Generic method hashCode() added. Please overwrite it, if you need better hashes. X-Git-Url: https://git.mxchange.org/?p=core.git;a=commitdiff_plain;h=46a806ba2ea6443c6927242b07f39842581e0eab;ds=sidebyside Generic method hashCode() added. Please overwrite it, if you need better hashes. --- diff --git a/inc/classes/interfaces/class_FrameworkInterface.php b/inc/classes/interfaces/class_FrameworkInterface.php index 5848674c..2859d7a3 100644 --- a/inc/classes/interfaces/class_FrameworkInterface.php +++ b/inc/classes/interfaces/class_FrameworkInterface.php @@ -31,6 +31,13 @@ interface FrameworkInterface { * @throws NullPointerException If the result instance is null */ function getField ($fieldName); + + /** + * Generates a code for hashes from this class + * + * @return $hashCode The hash code respresenting this class + */ + function hashCode (); } // diff --git a/inc/classes/main/class_BaseFrameworkSystem.php b/inc/classes/main/class_BaseFrameworkSystem.php index 8976961e..5f961a1c 100644 --- a/inc/classes/main/class_BaseFrameworkSystem.php +++ b/inc/classes/main/class_BaseFrameworkSystem.php @@ -1115,6 +1115,17 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { $this->partialStub('Developer mode inactive. Message:' . $message); } } + + /** + * Generates a generic hash code of this class. You should really overwrite + * this method with your own hash code generator code. But keep KISS in mind. + * + * @return $hashCode A generic hash code respresenting this whole class + */ + public function hashCode () { + // Simple hash code + return crc32($this->__toString()); + } } // [EOF] diff --git a/inc/config/class_FrameworkConfiguration.php b/inc/config/class_FrameworkConfiguration.php index 7692132a..0494722e 100644 --- a/inc/config/class_FrameworkConfiguration.php +++ b/inc/config/class_FrameworkConfiguration.php @@ -302,7 +302,16 @@ class FrameworkConfiguration implements Registerable { public final function getField ($fieldName) { // Our super interface "FrameworkInterface" requires this } + + /** + * Generates a code for hashes from this class + * + * @return $hashCode The hash code respresenting this class + */ + public function hashCode () { + return crc32($this->__toString()); + } } -// [EOF] +// ?>