Skip to content

Commit

Permalink
Merge pull request #62 from CrazyTapok-bit/hotfix/explode-error
Browse files Browse the repository at this point in the history
Parser bug (#61)
  • Loading branch information
CrazyTapok-bit authored Sep 8, 2023
2 parents 4ad6ddb + 0fe6f74 commit 2fa940c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Validator/InitDataValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function parse(string $data): array

return array_merge(...array_map(
function($item) {
if(strpos($item, '=') === false) return [];
[$prop, $value] = explode('=', $item);
return [$prop => $value];
},
Expand Down
7 changes: 7 additions & 0 deletions tests/Validator/InitDataValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ public function testFail(): void
$this->assertFalse($result);
}

public function testFailEmpty(): void
{
$result = $this->validator->validate('');

$this->assertFalse($result);
}

public function testException(): void
{
$this->validator = new InitDataValidator('5854973744:AAFnq4HoybEzqCJ-8HYHY_zlvkc_-H-kXq4', true);
Expand Down

0 comments on commit 2fa940c

Please sign in to comment.