示例#1
0
 /**
  * @brief Test an UUID to see if it is valid
  *
  * @param string $uuid The UUID
  * @return bool True if the UUID is valid.
  */
 public function test($uuid)
 {
     $hu = null;
     \uuid_create($hu);
     $status = \uuid_parse($hu, $uuid);
     $ret = $status === 0;
     // \uuid_destroy($hu);
     return $ret;
 }
示例#2
0
 /**
  * Generates a string of random binary data of the specified length
  *
  * @param integer $length The number of bytes of random binary data to generate
  * @return string A binary string
  */
 public function generate($length)
 {
     $uuid = uuid_create(UUID_TYPE_RANDOM);
     return uuid_parse($uuid);
 }
示例#3
0
 /**
  * Generate a version 1 UUID using the PECL UUID extension
  *
  * @param int|string $node Not used in this context
  * @param int $clockSeq Not used in this context
  * @return string A binary string
  */
 public function generate($node = null, $clockSeq = null)
 {
     $uuid = uuid_create(UUID_TYPE_TIME);
     return uuid_parse($uuid);
 }