Skip to content

Commit

Permalink
Improve implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
nyamsprod committed Mar 27, 2024
1 parent ecfca43 commit 24c736f
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/Base32/Base32.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
use RuntimeException;
use ValueError;

use function array_key_exists;
use function chr;
use function rtrim;
use function str_replace;
use function str_split;
use function strcspn;
use function strlen;
use function strpos;
use function strtoupper;
use function substr;
use function unpack;

final class Base32
{
private const ALPHABET_SIZE = 32;
Expand Down Expand Up @@ -125,9 +137,12 @@ public function decode(string $encoded, bool $strict = false): string
throw new RuntimeException('The encoded data length is invalid.');
}

$remainderStr = '';
for ($index = 0; $index < $remainder; $index++) {
$encoded .= $padding;
$remainderStr .= $padding;
}

$encoded .= $remainderStr;
}

$chars = [];
Expand Down

0 comments on commit 24c736f

Please sign in to comment.