Add fromDateTime() to create version 1 UUIDs from DateTime instances

Fixes #28
This commit is contained in:
Ben Ramsey
2020-02-03 00:48:41 -06:00
parent e269c16cd4
commit 5fa4eb4f17
13 changed files with 265 additions and 5 deletions
+20
View File
@@ -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;
}