Skip to content

Commit

Permalink
Update UUID.php
Browse files Browse the repository at this point in the history
  • Loading branch information
abmmhasan committed Apr 27, 2024
1 parent 0a46722 commit 69b6faf
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/UUID.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ private static function isValid(string $uuid): bool
*/
private static function getTime(string $uuid): DateTimeInterface
{
$uuid = str_getcsv($uuid, '-');
$uuid = explode('-', $uuid);
$version = (int)$uuid[2][0];
$timestamp = match ($version) {
1 => substr($uuid[2], -3) . $uuid[1] . $uuid[0],
Expand All @@ -262,7 +262,7 @@ private static function getTime(string $uuid): DateTimeInterface
default:
$timestamp = base_convert($timestamp, 16, 10);
$epochNanoseconds = bcsub($timestamp, self::$timeOffset);
$time = str_getcsv(bcdiv($epochNanoseconds, self::$secondIntervals, 6), '.');
$time = explode('.', bcdiv($epochNanoseconds, self::$secondIntervals, 6));
}

return new DateTimeImmutable(
Expand All @@ -282,8 +282,8 @@ private static function getTime(string $uuid): DateTimeInterface
private static function getUnixTimeSubSec(int $version = 1): array
{
$timestamp = microtime();
$unixTs = intval(substr($timestamp, 11));
$subSec = intval(substr($timestamp, 2, 7));
$unixTs = (int)substr($timestamp, 11);
$subSec = (int)substr($timestamp, 2, 7);
if ($version === 1) {
return [$unixTs, $subSec];
}
Expand Down

0 comments on commit 69b6faf

Please sign in to comment.