Creates a new V4 UUID

@return GUID
971961
public static function create(): GUID
    {
        $guid = \random_bytes(16);

        // Reset version byte to version 4 (0100)
        $guid[6] = chr(ord($guid[6]) & 0x0f | 0x40);

        $guid[8] = chr(ord($guid[8]) & 0x3f | 0x80);

        return new static($guid);
    }
800256
public function uuid()
    {
        $arr = array_values(unpack('N1a/n4b/N1c', openssl_random_pseudo_bytes(16)));
        $arr[2] = ($arr[2] & 0x0fff) | 0x4000;
        $arr[3] = ($arr[3] & 0x3fff) | 0x8000;
        return vsprintf('%08x-%04x-%04x-%04x-%04x%08x', $arr);
    }
1097035
protected function saveDrupalUuid()
    {
        $config = ProjectX::getProjectConfig();
        $options[static::getTypeId()] = [
            'build_info' => [
                'uuid' => $this->getDrupalUuid()
            ]
        ];

        $config
            ->setOptions($options)
            ->save(ProjectX::getProjectPath());

        return $this;
    }
206564
public function setUuid($uuid)
    {
        if (!is_null($uuid)) {
            $uuid = (string) $uuid;
        }

        $this->uuid = $uuid;
        return $this;
    }
14993
public static function uuid() {
		$uuid = static::random(16);
		$uuid[6] = chr(ord($uuid[6]) & static::UUID_CLEAR_VER | static::UUID_VERSION_4);
		$uuid[8] = chr(ord($uuid[8]) & static::UUID_CLEAR_VAR | static::UUID_VAR_RFC);

		return join('-', array(
			bin2hex(substr($uuid, 0, 4)),
			bin2hex(substr($uuid, 4, 2)),
			bin2hex(substr($uuid, 6, 2)),
			bin2hex(substr($uuid, 8, 2)),
			bin2hex(substr($uuid, 10, 6))
		));
	}
77048
public static function uuid4()
    {
        $bytes = self::generateBytes(16);

        // When converting the bytes to hex, it turns into a 32-character
        // hexadecimal string that looks a lot like an MD5 hash, so at this
        // point, we can just pass it to uuidFromHashedName.
        $hex = bin2hex($bytes);
        return self::uuidFromHashedName($hex, 4);
    }
7546
public static String makeGUID() {
        String uuid = "";
        String chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
        int rnd = 0;
        int r;

        for (int i = 0; i < GUID_STRING_LENGTH; i += 1) {
            if (i == 8 || i == 13 ||  i == 18 || i == 23) {
                uuid = uuid + "-";
            } else if (i == 14) {
                uuid = uuid + "4";
            } else {
                if (rnd <= 0x02) {
                    rnd = (int) (0x2000000 + Math.round(java.lang.Math.random() * 0x1000000));
                }
                r = rnd & 0xf;
                rnd = rnd >> 4;

                if (i == 19) {
                    uuid = uuid + chars.charAt((r & 0x3) | 0x8);
                } else {
                    uuid = uuid + chars.charAt(r);
                }
            }
        }
        return uuid;
    }
778824
protected static function bootUuid()
    {
        static::creating(function ($model) {
            if (! Generator::isValid($model->{$model->getKeyName()})) {
                $model->{$model->getKeyName()} = Generator::uuid4()->toString();
            }
        });
    }
337024
public static function uuid()
    {
        $node = getenv('SERVER_ADDR');
        if (strpos($node, ':') !== false) {
            if (substr_count($node, '::')) {
                $node = str_replace(
                    '::',
                    str_repeat(':0000', 8 - substr_count($node, ':')) . ':',
                    $node
                );
            }
            $node = explode(':', $node);
            $ipSix = '';
            foreach ($node as $id) {
                $ipSix .= str_pad(base_convert($id, 16, 2), 16, 0, STR_PAD_LEFT);
            }
            $node = base_convert($ipSix, 2, 10);
            if (strlen($node) < 38) {
                $node = null;
            } else {
                $node = crc32($node);
            }
        } elseif (empty($node)) {
            $host = getenv('HOSTNAME');
            if (empty($host)) {
                $host = getenv('HOST');
            }
            if (!empty($host)) {
                $ip = gethostbyname($host);
                if ($ip === $host) {
                    $node = crc32($host);
                } else {
                    $node = ip2long($ip);
                }
            }
        } elseif ($node !== '127.0.0.1') {
            $node = ip2long($node);
        } else {
            $node = null;
        }
        if (empty($node)) {
            $node = crc32(Strata::app()->getConfig('security.salt'));
        }
        if (function_exists('hphp_get_thread_id')) {
            $pid = hphp_get_thread_id();
        } elseif (function_exists('zend_thread_id')) {
            $pid = zend_thread_id();
        } else {
            $pid = getmypid();
        }
        if (!$pid || $pid > 65535) {
            $pid = mt_rand(0, 0xfff) | 0x4000;
        }
        list($timeMid, $timeLow) = explode(' ', microtime());
        return sprintf(
            "%08x-%04x-%04x-%02x%02x-%04x%08x",
            (int)$timeLow,
            (int)substr($timeMid, 2) & 0xffff,
            mt_rand(0, 0xfff) | 0x4000,
            mt_rand(0, 0x3f) | 0x80,
            mt_rand(0, 0xff),
            $pid,
            $node
        );
    }
682118
public function newUuid(){
        $q = Db::query('SELECT REPLACE(UUID(),"-","") as id');

        while($row = $q['result']->fetch_assoc()){
            $this->uuid = strtoupper($row['id']);
        }
        return $this;
    }
1007821
public function generateGuid()
    {
        if (function_exists('com_create_guid') === true) {
            return trim(com_create_guid(), '{}');
        }

        return sprintf(
            '%04X%04X-%04X-%04X-%04X-%04X%04X%04X',
            mt_rand(0, 65535),
            mt_rand(0, 65535),
            mt_rand(0, 65535),
            mt_rand(16384, 20479),
            mt_rand(32768, 49151),
            mt_rand(0, 65535),
            mt_rand(0, 65535),
            mt_rand(0, 65535)
        );
    }
753039
public function generateUuid()
    {
        $serialized = serialize($this->envInformations);
        $this->uuid = dechex($this->getDate()->format('Ymd')) . substr(sha1(implode([
            microtime(),
            $serialized,
            $this->configPath,
        ])), 0, -7);
    }
531109
protected static function bootUuid()
    {
        /**
         * Attach to the 'creating' Model Event to provide a UUID
         * for the `id` field (provided by $model->getKeyName())
         */
        static::creating(function ($model) {
            $key = $model->getKeyName();

            if (empty($model->$key)) {
                $model->$key = (string) $model->generateNewUuid();
            }
        });
    }
1092390
private static function fromRamseyUuid(\Ramsey\Uuid\Uuid $uuid)
    {
        return new self(
            $uuid->getFieldsHex(),
            $uuid->getNumberConverter(),
            \Ramsey\Uuid\Uuid::getFactory()->getCodec()
        );
    }
1079851
public static function orderedUuid()
    {
        $factory = new UuidFactory;

        $factory->setRandomGenerator(new CombGenerator(
            $factory->getRandomGenerator(),
            $factory->getNumberConverter()
        ));

        $factory->setCodec(new TimestampFirstCombCodec(
            $factory->getUuidBuilder()
        ));

        return $factory->uuid4();
    }
589755
public function getUuid()
    {
        /** @var Uuid $constraint */
        if ($constraint = $this->docBlockUtility->getConstraint($this->property, Uuid::class)) {
            return ($constraint->strict) ? self::UUID_CONSTRAINT_STRICT_VALUE : self::UUID_CONSTRAINT_NON_STRICT_VALUE;
        }
    }
958438
public function setUid(\FOM\UserBundle\Entity\User $uid)
    {
        $this->uid = $uid;

        return $this;
    }