Browse Source

Do not use 'self' construct referring to current class.

release/v0.1
Rafal Kupiec 1 year ago
parent
commit
3184b95a09
Signed by: belliash GPG Key ID: 4E829243E0CFE6B4
2 changed files with 10 additions and 10 deletions
  1. +9
    -9
      tests/base32_test.aer
  2. +1
    -1
      tests/exception_handler.aer

+ 9
- 9
tests/base32_test.aer View File

@ -25,26 +25,26 @@ class Base32 {
string $base32 = '';
$i = 0;
while($i < sizeof($fiveBitBinaryArray)) {
$base32 += self::$map[base_convert(str_pad($fiveBitBinaryArray[$i], 5,'0'), 2, 10)];
$base32 += Base32::$map[base_convert(str_pad($fiveBitBinaryArray[$i], 5,'0'), 2, 10)];
$i++;
}
int $x;
if($padding && ($x = strlen($binaryString) % 40) != 0) {
if($x == 8) $base32 += str_repeat(self::$map[32], 6);
else if($x == 16) $base32 += str_repeat(self::$map[32], 4);
else if($x == 24) $base32 += str_repeat(self::$map[32], 3);
else if($x == 32) $base32 += self::$map[32];
if($x == 8) $base32 += str_repeat(Base32::$map[32], 6);
else if($x == 16) $base32 += str_repeat(Base32::$map[32], 4);
else if($x == 24) $base32 += str_repeat(Base32::$map[32], 3);
else if($x == 32) $base32 += Base32::$map[32];
}
return $base32;
}
public static string decode(string $input) {
if(!$input) return '';
int $paddingCharCount = substr_count($input, self::$map[32]);
int $paddingCharCount = substr_count($input, Base32::$map[32]);
int[] $allowedValues = {6, 4, 3, 1, 0};
if(!in_array($paddingCharCount, $allowedValues)) return NULL;
for(int $i = 0; $i < 4; $i++) {
if($paddingCharCount == $allowedValues[$i] && substr($input, -($allowedValues[$i])) != str_repeat(self::$map[32], $allowedValues[$i]))
if($paddingCharCount == $allowedValues[$i] && substr($input, -($allowedValues[$i])) != str_repeat(Base32::$map[32], $allowedValues[$i]))
return false;
}
$input = str_replace('=','', $input);
@ -52,10 +52,10 @@ class Base32 {
string $binaryString = '';
for($i = 0; $i < sizeof($aInput); $i = $i + 8) {
string $x = '';
if(!in_array($input[$i], self::$map))
if(!in_array($input[$i], Base32::$map))
return false;
for(int $j = 0; $j < 8; $j++) {
$x += str_pad(base_convert(self::$flippedMap[$input[$i + $j]], 10, 2), 5, '0', STR_PAD_LEFT);
$x += str_pad(base_convert(Base32::$flippedMap[$input[$i + $j]], 10, 2), 5, '0', STR_PAD_LEFT);
}
string[] $eightBits = str_split($x, 8);
for(int $z = 0; $z < sizeof($eightBits); $z++) {

+ 1
- 1
tests/exception_handler.aer View File

@ -5,7 +5,7 @@ class ExceptionHandler {
}
public static void handleException(Exception $e) {
self::printException($e);
ExceptionHandler::printException($e);
}
}

Loading…
Cancel
Save