public static function guid()
{
return sprintf('%s-%s-%s-%s-%s', bin2hex(openssl_random_pseudo_bytes(4)), bin2hex(openssl_random_pseudo_bytes(2)), bin2hex(openssl_random_pseudo_bytes(2)), bin2hex(openssl_random_pseudo_bytes(2)), bin2hex(openssl_random_pseudo_bytes(6)));
}
public function testGuid() { $guid = Util::guid(); // ensure proper length $this->assertEquals(36, strlen($guid)); // Make sure in proper format $guid = explode('-', $guid); $this->assertEquals(8, strlen($guid[0])); $this->assertEquals(4, strlen($guid[1])); $this->assertEquals(4, strlen($guid[2])); $this->assertEquals(4, strlen($guid[3])); $this->assertEquals(12, strlen($guid[4])); }