From: Jan Schneider Date: Tue, 8 Sep 2009 21:55:17 +0000 (+0200) Subject: Add Horde_Support_Guid to generate the Horde-style GUIDs. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=a2362bc321848e5a3191a07b039eda951d8ac268;p=horde.git Add Horde_Support_Guid to generate the Horde-style GUIDs. --- diff --git a/framework/Support/lib/Horde/Support/Guid.php b/framework/Support/lib/Horde/Support/Guid.php new file mode 100644 index 000000000..6b445165c --- /dev/null +++ b/framework/Support/lib/Horde/Support/Guid.php @@ -0,0 +1,65 @@ + + * + * + * + * @category Horde + * @package Support + * @copyright 2009 The Horde Project (http://www.horde.org/) + * @license http://opensource.org/licenses/bsd-license.php + */ +class Horde_Support_Guid +{ + /** + * Generated GUID + * @var string + */ + private $_guid; + + /** + * New GUID + */ + public function __construct() + { + $this->generate(); + } + + /** + * Generates a GUID. + * + * @return string + */ + public function generate() + { + $this->_guid = date('YmdHis') + . '.' + . substr(str_pad(base_convert(microtime(), 10, 36), 16, uniqid(mt_rand()), STR_PAD_LEFT), -16) + . '@' + . (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'localhost'); + } + + /** + * Cooerce to string + * + * @return string + */ + public function __toString() + { + return $this->_guid; + } + +} diff --git a/framework/Support/package.xml b/framework/Support/package.xml index 4b6704fb9..b6ba89252 100644 --- a/framework/Support/package.xml +++ b/framework/Support/package.xml @@ -50,6 +50,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> + @@ -76,6 +77,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> +