PHP 8.3.31
Preview: UuidV1.php Size: 2.36 KB
/home/getspomw/royalsquad.us/vendor/symfony/uid/UuidV1.php

<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Symfony\Component\Uid;

/**
 * A v1 UUID contains a 60-bit timestamp and 62 extra unique bits.
 *
 * @author Grégoire Pineau <lyrixx@lyrixx.info>
 */
class UuidV1 extends Uuid implements TimeBasedUidInterface
{
    protected const TYPE = 1;

    private static string $clockSeq;

    public function __construct(?string $uuid = null)
    {
        if (null === $uuid) {
            $this->uid = strtolower(uuid_create(static::TYPE));
        } else {
            parent::__construct($uuid, true);
        }
    }

    public function getDateTime(): \DateTimeImmutable
    {
        return BinaryUtil::hexToDateTime('0'.substr($this->uid, 15, 3).substr($this->uid, 9, 4).substr($this->uid, 0, 8));
    }

    public function getNode(): string
    {
        return substr($this->uid, -12);
    }

    public function toV6(): UuidV6
    {
        $uuid = $this->uid;

        return new UuidV6(substr($uuid, 15, 3).substr($uuid, 9, 4).$uuid[0].'-'.substr($uuid, 1, 4).'-6'.substr($uuid, 5, 3).substr($uuid, 18, 6).substr($uuid, 24));
    }

    public function toV7(): UuidV7
    {
        return $this->toV6()->toV7();
    }

    public static function generate(?\DateTimeInterface $time = null, ?Uuid $node = null): string
    {
        $uuid = !$time || !$node ? uuid_create(static::TYPE) : parent::NIL;

        if ($time) {
            if ($node) {
                // use clock_seq from the node
                $seq = substr($node->uid, 19, 4);
            } elseif (!$seq = self::$clockSeq ?? '') {
                // generate a static random clock_seq to prevent any collisions with the real one
                $seq = substr($uuid, 19, 4);

                do {
                    self::$clockSeq = \sprintf('%04x', random_int(0, 0x3FFF) | 0x8000);
                } while ($seq === self::$clockSeq);

                $seq = self::$clockSeq;
            }

            $time = BinaryUtil::dateTimeToHex($time);
            $uuid = substr($time, 8).'-'.substr($time, 4, 4).'-1'.substr($time, 1, 3).'-'.$seq.substr($uuid, 23);
        }

        if ($node) {
            $uuid = substr($uuid, 0, 24).substr($node->uid, 24);
        }

        return $uuid;
    }
}

Directory Contents

Dirs: 2 × Files: 22

Name Size Perms Modified Actions
Command DIR
- drwxrwxrwx 2026-04-21 17:33:13
Edit Download
Factory DIR
- drwxrwxrwx 2025-09-17 06:53:22
Edit Download
5.09 KB lrw-rw-rw- 2025-09-17 06:53:22
Edit Download
6.37 KB lrw-rw-rw- 2025-09-17 06:53:22
Edit Download
1.27 KB lrw-rw-rw- 2025-09-17 06:53:22
Edit Download
917 B lrw-rw-rw- 2025-09-17 06:53:22
Edit Download
23.18 KB lrw-r--r-- 2026-04-27 08:47:25
Edit Download
636 B lrw-rw-rw- 2025-09-17 06:53:22
Edit Download
1.04 KB lrw-rw-rw- 2025-09-17 06:53:22
Edit Download
383 B lrw-rw-rw- 2025-09-17 06:53:22
Edit Download
415 B lrw-rw-rw- 2025-09-17 06:53:22
Edit Download
383 B lrw-rw-rw- 2025-09-17 06:53:22
Edit Download
472 B lrw-rw-rw- 2025-09-17 06:53:22
Edit Download
604 B lrw-rw-rw- 2025-09-17 06:53:22
Edit Download
519 B lrw-rw-rw- 2025-09-17 06:53:22
Edit Download
6.88 KB lrw-rw-rw- 2025-09-17 06:53:22
Edit Download
7.36 KB lrw-rw-rw- 2025-09-17 06:53:22
Edit Download
2.36 KB lrw-rw-rw- 2025-09-17 06:53:22
Edit Download
592 B lrw-rw-rw- 2025-09-17 06:53:22
Edit Download
1.33 KB lrw-rw-rw- 2025-09-17 06:53:22
Edit Download
592 B lrw-rw-rw- 2025-09-17 06:53:22
Edit Download
3.01 KB lrw-rw-rw- 2025-09-17 06:53:22
Edit Download
5.00 KB lrw-rw-rw- 2025-09-17 06:53:22
Edit Download
573 B lrw-rw-rw- 2025-09-17 06:53:22
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).