diff --git a/src/Ulid.php b/src/Ulid.php index 1d10b76..293ff52 100644 --- a/src/Ulid.php +++ b/src/Ulid.php @@ -67,6 +67,9 @@ public function getRandomString():string { private function base32(int $number):string { $skipCharacters = ["i", "l", "o", "u"]; + if($number < 0) { + $number = -$number; + } $converted = base_convert((string)$number, 10, 32); for($i = 0, $len = strlen($converted); $i < $len; $i++) { diff --git a/test/phpunit/UlidTest.php b/test/phpunit/UlidTest.php index 696cd3e..4833631 100644 --- a/test/phpunit/UlidTest.php +++ b/test/phpunit/UlidTest.php @@ -51,7 +51,6 @@ public function testToString_containsNoAmbiguousCharacters():void { for($i = 0; $i < 1_000; $i++) { $sut = new Ulid(); foreach($skipCharacters as $char) { - echo $sut, PHP_EOL; self::assertStringNotContainsString($char, $sut); } } @@ -76,7 +75,6 @@ public function testConstruct_setTimestampLength():void { for($i = 0; $i < 10; $i++) { $tLength = rand(5, 10); $sut = new Ulid(timestampLength: $tLength); - echo $sut, PHP_EOL; $tString = $sut->getTimestampString(); self::assertSame($tLength, strlen($tString)); }