CoreFiles by mySites.guru
TimeBasedUuidFactory.php44 lines, 1,029 bytes, from Joomla_5.3.2-Stable-Full_Package.zip
Raw History Compare with 5.3.1
md5
2337d8966a3bf5dd14b2edd2cc6d83db
sha1
55a1d6b2e72577085c0e0341cf26c3aba2c0be09
sha256
2d253273c5c2e9264c46a4f043caa46afd46653309451a41b3eb0c37ad98c323
<?php

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

namespace Symfony\Component\Uid\Factory;

use Symfony\Component\Uid\TimeBasedUidInterface;
use Symfony\Component\Uid\Uuid;

class TimeBasedUuidFactory
{
    /**
     * @var class-string<Uuid&TimeBasedUidInterface>
     */
    private string $class;
    private ?Uuid $node;

    /**
     * @param class-string<Uuid&TimeBasedUidInterface> $class
     */
    public function __construct(string $class, ?Uuid $node = null)
    {
        $this->class = $class;
        $this->node = $node;
    }

    public function create(?\DateTimeInterface $time = null): Uuid&TimeBasedUidInterface
    {
        $class = $this->class;

        if (null === $time && null === $this->node) {
            return new $class();
        }

        return new $class($class::generate($time, $this->node));
    }
}

The same content is in 136 releases, Joomla 5.1.0-beta1 to 6.3.0-alpha1. See them all, or every version of this file.