Dump the UUID as a string.

@param bool $compact Dump UUID without dashes?
188048
public function toString(bool $compact = false): string
    {
        if ($compact) {
            return \bin2hex($this->value);
        }
        
        return \vsprintf('%s%s-%s-%s-%s-%s%s%s', \str_split(\bin2hex($this->value), 4));
    }
796761
final private function generateUuid()
    {
        return sprintf(
            '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
            // 32 bits for "time_low"
            mt_rand(0, 0xffff),
            mt_rand(0, 0xffff),
            // 16 bits for "time_mid"
            mt_rand(0, 0xffff),
            // 16 bits for "time_hi_and_version",
            // four most significant bits holds version number 4
            mt_rand(0, 0x0fff) | 0x4000,
            // 16 bits, 8 bits for "clk_seq_hi_res",
            // 8 bits for "clk_seq_low",
            // two most significant bits holds zero and one for variant DCE1.1
            mt_rand(0, 0x3fff) | 0x8000,
            // 48 bits for "node"
            mt_rand(0, 0xffff),
            mt_rand(0, 0xffff),
            mt_rand(0, 0xffff)
        );
    }
1165399
public function serializeMetaKey($ident)
    {
        if (is_array($ident)) {
            sort($ident);
            $ident = implode(':', $ident);
        }

        return md5($ident);
    }
1338730
public function json($pretty=FALSE) {
		if($pretty) {
			$sorted = $this->payload;
			$this->sortRecursive($sorted);
			return json_encode($sorted, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
		} else {
			return json_encode($this->payload);
		}
	}
507004
public static function isValid(string $uuid): bool
    {
        $uuid = strtolower(str_replace(['urn:', 'uuid:', '{', '}'], '', $uuid));

        if (!preg_match(static::UUID, $uuid)) {
            return false;
        }

        return true;
    }
527097
protected function extractComponents($encodedUuid)
    {
        $nameParsed = str_replace([
            'urn:',
            'uuid:',
            '{',
            '}',
            '-'
        ], '', $encodedUuid);

        // We have stripped out the dashes and are breaking up the string using
        // substr(). In this way, we can accept a full hex value that doesn't
        // contain dashes.
        $components = [
            substr($nameParsed, 0, 8),
            substr($nameParsed, 8, 4),
            substr($nameParsed, 12, 4),
            substr($nameParsed, 16, 4),
            substr($nameParsed, 20)
        ];

        $nameParsed = implode('-', $components);

        if (!Uuid::isValid($nameParsed)) {
            throw new InvalidUuidStringException('Invalid UUID string: ' . $encodedUuid);
        }

        return $components;
    }
407549
public function delete($key, $compact=true){
        $this->set($key, null);
        if ($compact) $this->compact();
    }
637488
public static function createUid(): string
    {
        $uid = str_replace('-', '', Uuid::uuid4()->toString());

        $checksum_a = 0; // a sum of the bytes
        $checksum_b = 0; // a sum of the incremental values of $checksum_a

        // Compute checksums
        for ($i = 0; $i < 32; $i += 2) {
            $checksum_a += hexdec(substr($uid, $i, 2));
            $checksum_b += $checksum_a & 0xff;
        }

        return strtoupper($uid . substr(dechex($checksum_a), -2) . substr(dechex($checksum_b), -2));
    }
596814
public static function stringify_identifier($identifier)
	{
		// Identifier may not be empty, but can be false or 0
		if ($identifier === '' || $identifier === null)
		{
			throw new \FuelException('The identifier cannot be empty, must contain a value of any kind other than null or an empty string.');
		}

		// In case of string or int just return it as a string
		if (is_string($identifier) || is_int($identifier))
		{
			// cleanup to only allow alphanum chars, dashes, dots & underscores
			if (preg_match('/^([a-z0-9_\.\-]*)$/iuD', $identifier) === 0)
			{
				throw new \FuelException('Cache identifier can only contain alphanumeric characters, underscores, dashes & dots.');
			}

			return (string) $identifier;
		}
		// In case of array, bool or object return the md5 of the $identifier's serialization
		else
		{
			return '_hashes.'.md5(serialize($identifier));
		}
	}
1014030
public function dump($all = false)
    {
        if ($all) {
            return $this->data;
        }

        $data = [];

        foreach (array_keys($this->getFields()) as $field) {
            $data[$field] = $this->data[$field];
        }

        return $data;
    }
608228
public function getFileFromUuid($uuid)
    {
        if ($path = $this->getPathFromUuid($uuid)) {
            if (is_dir($this->container->get('huh.utils.container')->getProjectDir().\DIRECTORY_SEPARATOR.$path)) {
                return null;
            }

            return new File($path);
        }
    }
916788
public function _generateUUIDString() {
        return sprintf("%08x%08x%08x%08x",
            $this->_util->randInt32(),
            $this->_util->randInt32(),
            $this->_util->randInt32(),
            $this->_util->randInt32()
        );
    }
680425
static public function uuid($value, $message = null, $propertyPath = null)
        {
            $value = str_replace(
                array(
                    'urn:',
                    'uuid:',
                    '{', '}'
                ),
                '',
                $value
            );

            if ($value === '00000000-0000-0000-0000-000000000000') {
                return;
            }

            if (!preg_match('/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[1-5][0-9A-Fa-f]{3}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/', $value)) {
                $message = $message ?: sprintf(
                    'Value "%s" is not a valid UUID.',
                    static::stringify($value)
                );

                throw static::createException($value, $message, static::INVALID_UUID, $propertyPath);
            }
        }
516896
public static function dump($data, bool $clean = true)
    {
        if ($clean) {
            /** @noinspection PhpStatementHasEmptyBodyInspection */
            /** @noinspection PhpUsageOfSilenceOperatorInspection */
            while (ob_get_level() && @ob_end_clean() !== false) {
                // Do nothing, just clean buffer
            }
        }

        // Represent supplied data
        switch (gettype($data)) {
            case 'boolean':

                echo 'Boolean: ' . ($data ? 'true' : 'false') . '<br>' . PHP_EOL;

                break;

            case 'string':

                echo 'String: ' . $data . '<br>'. PHP_EOL;

                break;

            case 'double':

                echo 'Double: ' . $data . '<br>'. PHP_EOL;

                break;

            case 'integer':

                echo 'Integer: ' . $data . '<br>'. PHP_EOL;

                break;

            case 'object':

                $methods = get_class_methods($data);

                if ($methods) {

                    natsort($methods);

                    $html = ['<table style="margin-left:50px">'];

                    foreach ($methods as $v) {
                        $html[] = '<tr><td>' . htmlspecialchars($v) . '()</td></tr>';
                    }

                    $html[] = '</table>';

                    $methods = implode('', $html);
                }

                $vars = get_object_vars($data);

                if ($vars) {

//                    natsort($vars);

                    $html = ['<table style="margin-left:50px">'];

                    foreach ($vars as $k => $v) {
                        $html[] = '<tr><td>' . htmlspecialchars((string)$k) . '</td><td>' . (is_string($v) ? htmlspecialchars($v) : '') . '</td></tr>';
                    }

                    $html[] = '</table>';

                    $vars = implode('', $html);
                }

                echo 'Object: <strong>' . get_class($data) . '</strong>' . ($methods ? '<br><br><strong>Methods</strong>: ' . $methods : '') . ($vars ? '<br><br><strong>Variables</strong>: ' . $vars : '') . '<br><br><strong>Data</strong>:<br><pre>' . print_r($data, true) . '</pre>';

                break;

            case 'resource':

                echo 'Resource: ' . get_resource_type($data) . '<br>'. PHP_EOL;

                break;

            case 'NULL':

                echo 'NULL'. PHP_EOL . '<br>';

                break;

            case 'array':

                echo '<pre>' . print_r($data, true) . '</pre>' . '<br>'. PHP_EOL;

                break;

            default:

                throw new \RuntimeException('Supplied data type is not supported');
        }

        self::outputDebugStackTable();

        // Show
        if (Settings::get('debug_panel')) {
            Stats::getView();
        }

        // No more output
        if ($clean) {
            exit;
        }
    }
732443
public static function uuid(string $prefix = ''): string {
		$chars = md5(uniqid($prefix, true));
		$uuid  = '';
		for ($i = 0; $i < 36; $i++)
			$uuid .= ($i === 8 || $i === 15 || $i === 20 || $i === 25) ? '-' : $chars[mt_rand(0, 31)];
		return $uuid;
	}
909951
public function _DumpString()
    {
        $cid = \Swoole\Coroutine::getuid();
        $ret="==== SwooleCoroutineSingleton List Current cid [{$cid}] ==== ;\n";
        foreach (self::$_instances as $cid=>$v) {
            foreach ($v as $cid_class=>$object) {
                $hash=$object?md5(spl_object_hash($object)):'';
                $class=$object?get_class($object):'';
                $class=$cid_class===$class?'':$class;
                $ret.="[$hash]$cid $cid_class($class)\n";
            }
        }
        return "{{$ret}}\n";
    }
1301130
public function encode(UuidInterface $uuid)
    {
        $sixPieceComponents = array_values($uuid->getFieldsHex());

        $this->swapTimestampAndRandomBits($sixPieceComponents);

        return vsprintf(
            '%08s-%04s-%04s-%02s%02s-%012s',
            $sixPieceComponents
        );
    }