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:
Marcel Berteler
2022-12-19 23:18:32 +02:00
committed by GitHub
parent 9fd59bb21c
commit 5e24bfd390
3 changed files with 74 additions and 2 deletions
+10
View File
@@ -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);
}
}