Skip to content

Commit

Permalink
Fix PhpStan errors
Browse files Browse the repository at this point in the history
  • Loading branch information
janbarasek committed Dec 14, 2020
1 parent 047873b commit b7acc39
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public static function getOtp(string $secret, string $timeSlot): int
$data = str_pad(pack('N', $timeSlot), 8, "\0", STR_PAD_LEFT);
$hash = hash_hmac('sha1', $data, $secret, true);
$offset = \ord(\substr($hash, -1)) & 0xF;
$unpacked = unpack('N', substr($hash, $offset, 4));
$unpacked = (array) unpack('N', substr($hash, $offset, 4));

return ($unpacked[1] & 0x7FFFFFFF) % 1e6;
}
Expand Down
9 changes: 6 additions & 3 deletions src/User/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -423,11 +423,14 @@ public function addLogin(UserLogin $login): void

public function getOtpCode(): ?string
{
if (is_resource($otpCode = $this->otpCode) === true) {
$otpCode = (string) stream_get_contents($otpCode);
if ($this->otpCode === null) {
return null;
}
if (is_resource($this->otpCode) === true) {
return (string) stream_get_contents($this->otpCode);
}

return $otpCode;
return (string) $this->otpCode;
}


Expand Down

0 comments on commit b7acc39

Please sign in to comment.