mirror of
https://github.com/ramsey/uuid.git
synced 2026-06-20 16:57:36 +03:00
feat: add Uuid:fromHexadecimal() (#309)
Co-authored-by: mberteler <marcel.berteler@capetown.gov.za> Co-authored-by: Ben Ramsey <ben@benramsey.com>
This commit is contained in:
@@ -312,6 +312,14 @@ class UuidFactory implements UuidFactoryInterface
|
||||
return $this->uuidFromBytesAndVersion($bytes, Uuid::UUID_TYPE_TIME);
|
||||
}
|
||||
|
||||
/**
|
||||
* @psalm-pure
|
||||
*/
|
||||
public function fromHexadecimal(Hexadecimal $hex): UuidInterface
|
||||
{
|
||||
return $this->codec->decode($hex->__toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
@@ -436,6 +444,7 @@ class UuidFactory implements UuidFactoryInterface
|
||||
*/
|
||||
public function uuid(string $bytes): UuidInterface
|
||||
{
|
||||
/** @psalm-suppress ImpurePropertyFetch */
|
||||
return $this->uuidBuilder->build($this->codec, $bytes);
|
||||
}
|
||||
|
||||
@@ -498,6 +507,7 @@ class UuidFactory implements UuidFactoryInterface
|
||||
return LazyUuidFromString::fromBytes($bytes);
|
||||
}
|
||||
|
||||
/** @psalm-suppress ImpureVariable */
|
||||
return $this->uuid($bytes);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user