From 46a806ba2ea6443c6927242b07f39842581e0eab Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 4 Aug 2009 23:23:54 +0000 Subject: [PATCH] Generic method hashCode() added. Please overwrite it, if you need better hashes. --- inc/classes/interfaces/class_FrameworkInterface.php | 7 +++++++ inc/classes/main/class_BaseFrameworkSystem.php | 11 +++++++++++ inc/config/class_FrameworkConfiguration.php | 11 ++++++++++- 3 files changed, 28 insertions(+), 1 deletion(-) 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] +// ?> -- 2.39.5