Skip to content

Commit

Permalink
Merge pull request #17 from infocyph/feature/update
Browse files Browse the repository at this point in the history
v1 fix
  • Loading branch information
abmmhasan authored Jun 8, 2024
2 parents 7ab4ae2 + b799174 commit bcee638
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 25 deletions.
38 changes: 19 additions & 19 deletions rector.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__ . '/src'
]);
$rectorConfig->sets([
constant("Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_82")
]);
$rectorConfig->skip([
StringClassNameToClassConstantRector::class
]);
};
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
use Rector\TypeDeclaration\Rector\ClassMethod\AddVoidReturnTypeWhereNoReturnRector;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__ . '/src'
]);
$rectorConfig->sets([
constant("Rector\Set\ValueObject\LevelSetList::UP_TO_PHP_82")
]);
$rectorConfig->skip([
StringClassNameToClassConstantRector::class
]);
};
10 changes: 4 additions & 6 deletions src/UUID.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,13 @@ final class UUID
public static function v1(string $node = null): string
{
[$unixTs, $subSec] = self::getUnixTimeSubSec();
$time = $unixTs . $subSec;
$time = str_pad(dechex((int)$time + self::$timeOffset), 16, '0', STR_PAD_LEFT);
$clockSeq = random_int(0, 0x3fff);
$time = str_pad(dechex((int)($unixTs . $subSec) + self::$timeOffset), 16, '0', STR_PAD_LEFT);
return sprintf(
'%08s-%04s-1%03s-%04x-%012s',
substr($time, -8),
substr($time, -12, 4),
substr($time, -15, 3),
$clockSeq | 0x8000,
random_int(0, 0x3fff) & 0x3fff | 0x8000,
$node ?? self::getNode()
);
}
Expand Down Expand Up @@ -323,8 +321,8 @@ private static function getTime(array $uuid, int $version): DateTimeInterface
private static function getUnixTimeSubSec(int $version = 1): array
{
$timestamp = microtime();
$unixTs = (int)substr($timestamp, 11);
$subSec = (int)substr($timestamp, 2, 7);
$unixTs = substr($timestamp, 11);
$subSec = substr($timestamp, 2, 7);
if ($version === 1) {
return [$unixTs, $subSec];
}
Expand Down

0 comments on commit bcee638

Please sign in to comment.