Skip to content

Commit

Permalink
Use case-insensitive character lookup when decoding time. Closes #19.
Browse files Browse the repository at this point in the history
  • Loading branch information
robinvdvleuten committed Sep 24, 2019
1 parent 6176bef commit 637ca08
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Ulid.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private function decodeTime(string $time): int
$carry = 0;

foreach ($timeChars as $index => $char) {
if (($encodingIndex = strrpos(static::ENCODING_CHARS, $char)) === false) {
if (($encodingIndex = strripos(static::ENCODING_CHARS, $char)) === false) {
throw new InvalidUlidStringException('Invalid ULID character: ' . $char);
}

Expand Down
1 change: 1 addition & 0 deletions tests/UlidTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,6 @@ public function testCreatesFromStringWithTrailingNewLine(): void
public function testConvertsToTimestamp(): void
{
$this->assertEquals(1561622862, Ulid::fromString('0001EH8YAEP8CXP4AMWCHHDBHJ')->toTimestamp());
$this->assertEquals(1561622862, Ulid::fromString('0001eh8yaep8cxp4amwchhdbhj', true)->toTimestamp());
}
}

0 comments on commit 637ca08

Please sign in to comment.