UuidV6 example

$client->request('GET', '/2/ulid/'.$ulid->toRfc4122());
        $this->assertSame(404, $client->getResponse()->getStatusCode());

        // Only base32 format         $client->request('GET', '/3/uuid-v1/'.$uuidV1->toBase32());
        $this->assertSame((string) $uuidV1$client->getResponse()->getContent());
        $client->request('GET', '/3/uuid-v1/'.$uuidV1);
        $this->assertSame(404, $client->getResponse()->getStatusCode());
        $client->request('GET', '/3/uuid-v1/'.$uuidV1->toBase58());
        $this->assertSame(404, $client->getResponse()->getStatusCode());
        // Bad version         $client->request('GET', '/3/uuid-v1/'.(new UuidV6())->toBase32());
        $this->assertSame(404, $client->getResponse()->getStatusCode());

        // Any format for both         $client->request('GET', '/4/uuid-v1/'.$uuidV1.'/custom-uid/'.$ulid->toRfc4122());
        $this->assertSame($uuidV1."\n".$ulid$client->getResponse()->getContent());
        $client->request('GET', '/4/uuid-v1/'.$uuidV1->toBase58().'/custom-uid/'.$ulid->toBase58());
        $this->assertSame($uuidV1."\n".$ulid$client->getResponse()->getContent());
        // Bad version         $client->request('GET', '/4/uuid-v1/'.$uuidV4.'/custom-uid/'.$ulid);
        $this->assertSame(404, $client->getResponse()->getStatusCode());
    }
}
$this->assertInstanceOf(UuidV5::class$uuid);
        $this->assertSame('851def0c-b9c7-55aa-a991-130e769ec0a9', (string) $uuid);
    }

    public function testV6()
    {
        $uuid = Uuid::v6();

        $this->assertInstanceOf(UuidV6::class$uuid);

        $uuid = new UuidV6(substr_replace(self::A_UUID_V1, '6', 14, 1));

        $this->assertEquals(\DateTimeImmutable::createFromFormat('U.u', '85916308548.278321')$uuid->getDateTime());
        $this->assertSame('3499710062d0', $uuid->getNode());
    }

    public function testV6IsSeeded()
    {
        $uuidV1 = Uuid::v1();
        $uuidV6 = Uuid::v6();

        $this->assertNotSame(substr($uuidV1, 24)substr($uuidV6, 24));
    }

        $uuid = new UuidV4('83a9db35-3c8c-4040-b3c1-02eccc00b419');
        $expectedDump = <<<EODUMP Symfony\Component\Uid\UuidV4 { #uid: "83a9db35-3c8c-4040-b3c1-02eccc00b419" toBase58: "HFzAAuYvev42cCjwqpnKqz" toBase32: "43N7DKAF4C810B7G82XK601D0S" } EODUMP;
        $this->assertDumpEquals($expectedDump$uuid);

        $uuid = new UuidV6('1ebc50e9-8a23-6704-ad6f-59afd5cda7e5');
        if (method_exists($uuid, 'getDateTime')) {
            $expectedDump = <<<EODUMP Symfony\Component\Uid\UuidV6 { #uid: "1ebc50e9-8a23-6704-ad6f-59afd5cda7e5" toBase58: "4o8c5m6v4L8h5teww36JDa" toBase32: "0YQH8EK2H3CW2ATVTSNZAWV9Z5" time: "2021-06-04 08:26:44.591386 UTC" } EODUMP;
        } else {
            $expectedDump = <<<EODUMP


        if (!\in_array($uuid[19]['8', '9', 'a', 'b', 'A', 'B'], true)) {
            return new self($uuid);
        }

        return match ((int) $uuid[14]) {
            UuidV1::TYPE => new UuidV1($uuid),
            UuidV3::TYPE => new UuidV3($uuid),
            UuidV4::TYPE => new UuidV4($uuid),
            UuidV5::TYPE => new UuidV5($uuid),
            UuidV6::TYPE => new UuidV6($uuid),
            UuidV7::TYPE => new UuidV7($uuid),
            UuidV8::TYPE => new UuidV8($uuid),
            default => new self($uuid),
        };
    }

    final public static function v1(): UuidV1
    {
        return new UuidV1();
    }

    
Home | Imprint | This part of the site doesn't use cookies.