mirror of
https://github.com/ramsey/uuid.git
synced 2026-06-14 15:56:48 +03:00
Add the getHex() method
This commit is contained in:
@@ -231,11 +231,8 @@ final class Uuid
|
||||
{
|
||||
$bytes = '';
|
||||
|
||||
$hex = $this->toString();
|
||||
$hex = str_replace('-', '', $hex);
|
||||
|
||||
foreach (range(-2, -32, 2) as $step) {
|
||||
$bytes = chr(hexdec(substr($hex, $step, 2))) . $bytes;
|
||||
$bytes = chr(hexdec(substr($this->getHex(), $step, 2))) . $bytes;
|
||||
}
|
||||
|
||||
return $bytes;
|
||||
@@ -423,6 +420,16 @@ final class Uuid
|
||||
return $this->fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the hexadecimal value of the UUID
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHex()
|
||||
{
|
||||
return str_replace('-', '', $this->toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the integer value of the UUID, represented as a BigNumber
|
||||
*
|
||||
@@ -440,11 +447,8 @@ final class Uuid
|
||||
);
|
||||
}
|
||||
|
||||
$hex = $this->toString();
|
||||
$hex = str_replace('-', '', $hex);
|
||||
|
||||
$number = \Moontoast\Math\BigNumber::baseConvert(
|
||||
$hex,
|
||||
$this->getHex(),
|
||||
16,
|
||||
10
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user