Do not use 'self' construct referring to current class.
The build was successful. Details

This commit is contained in:
Rafal Kupiec 2019-06-03 12:23:42 +02:00
parent 5f90f3e8e1
commit 3184b95a09
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
2 changed files with 10 additions and 10 deletions

View File

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

View File

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