NameBasedUuidFactory example

return new TimeBasedUuidFactory($this->timeBasedClass, $node);
    }

    public function nameBased(Uuid|string $namespace = null): NameBasedUuidFactory
    {
        $namespace ??= $this->nameBasedNamespace;

        if (null === $namespace) {
            throw new \LogicException(sprintf('A namespace should be defined when using "%s()".', __METHOD__));
        }

        return new NameBasedUuidFactory($this->nameBasedClass, $this->getNamespace($namespace));
    }

    private function getNamespace(Uuid|string $namespace): Uuid
    {
        if ($namespace instanceof Uuid) {
            return $namespace;
        }

        return match ($namespace) {
            'dns' => new UuidV1(Uuid::NAMESPACE_DNS),
            'url' => new UuidV1(Uuid::NAMESPACE_URL),
            
Home | Imprint | This part of the site doesn't use cookies.