mirror of
https://github.com/ramsey/uuid.git
synced 2026-06-14 15:56:48 +03:00
Add fromDateTime() to create version 1 UUIDs from DateTime instances
Fixes #28
This commit is contained in:
@@ -14,6 +14,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Ramsey\Uuid\Type\Hexadecimal;
|
||||
use Ramsey\Uuid\Type\IntegerValue;
|
||||
use Ramsey\Uuid\Validator\ValidatorInterface;
|
||||
@@ -139,4 +140,23 @@ interface UuidFactoryInterface
|
||||
* @psalm-pure
|
||||
*/
|
||||
public function fromInteger(string $integer): UuidInterface;
|
||||
|
||||
/**
|
||||
* Creates a UUID from a DateTimeInterface instance
|
||||
*
|
||||
* @param DateTimeInterface $dateTime The date and time
|
||||
* @param Hexadecimal|null $node A 48-bit number representing the hardware
|
||||
* address
|
||||
* @param int|null $clockSeq A 14-bit number used to help avoid duplicates
|
||||
* that could arise when the clock is set backwards in time or if the
|
||||
* node ID changes
|
||||
*
|
||||
* @return UuidInterface A UuidInterface instance that represents a
|
||||
* version 1 UUID created from a DateTimeInterface instance
|
||||
*/
|
||||
public function fromDateTime(
|
||||
DateTimeInterface $dateTime,
|
||||
?Hexadecimal $node = null,
|
||||
?int $clockSeq = null
|
||||
): UuidInterface;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user