Skip to content

Commit

Permalink
fix: resolve Encryption/Cypher/* PSR-4 Autoload bug caused by a misty…
Browse files Browse the repository at this point in the history
…po, run php-cs-fixer
  • Loading branch information
mauriziofonte committed Sep 3, 2021
1 parent 8cbf9a8 commit 71d9ee2
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 61 deletions.
99 changes: 49 additions & 50 deletions src/Compression/Gzip/GzipCompression.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,64 +2,63 @@

namespace Mfonte\Base62x\Compression\Gzip;

use Mfonte\Base62x\Exception\CompressionException;
use Mfonte\Base62x\Exception\CompressionException;

class GzipCompression
class GzipCompression
{
public static function encode($data, $encoding = null)
{
public static function encode($data, $encoding = null)
{
if (!\function_exists('gzencode')) {
throw new CompressionException('gzip', 'Cannot use Gzip as compression algorithm: the current PHP installation does not support this module.');
}

$encoded = false;
switch ($encoding) {
case 'zlib':
$encoded = \gzcompress($data, 9);
break;
case 'deflate':
$encoded = \gzdeflate($data, 9);
break;
case 'gzip':
$encoded = \gzencode($data, 9);
break;
break;
default:
$encoded = \gzencode($data, 9);
}
if (!\function_exists('gzencode')) {
throw new CompressionException('gzip', 'Cannot use Gzip as compression algorithm: the current PHP installation does not support this module.');
}

if ($encoded === false) {
throw new CompressionException('gzip', 'The gz compression function returned a false state while compressing the input data.');
}
$encoded = false;
switch ($encoding) {
case 'zlib':
$encoded = \gzcompress($data, 9);
break;
case 'deflate':
$encoded = \gzdeflate($data, 9);
break;
case 'gzip':
$encoded = \gzencode($data, 9);
break;
default:
$encoded = \gzencode($data, 9);
}

return $encoded;
if ($encoded === false) {
throw new CompressionException('gzip', 'The gz compression function returned a false state while compressing the input data.');
}

public static function decode($data, $encoding = null)
{
if (!\function_exists('gzdecode')) {
throw new CompressionException('gzip', 'Cannot use Gzip as compression algorithm: the current PHP installation does not support this module.');
}
return $encoded;
}

$decoded = false;
switch ($encoding) {
case 'zlib':
$decoded = \gzuncompress($data);
break;
case 'deflate':
$decoded = \gzinflate($data);
break;
case 'gzip':
$decoded = \gzdecode($data);
break;
default:
$decoded = \gzdecode($data);
}
public static function decode($data, $encoding = null)
{
if (!\function_exists('gzdecode')) {
throw new CompressionException('gzip', 'Cannot use Gzip as compression algorithm: the current PHP installation does not support this module.');
}

if ($decoded === false) {
throw new CompressionException('gzip', 'The gz decompression function returned a false state while uncompressing the input data.');
}
$decoded = false;
switch ($encoding) {
case 'zlib':
$decoded = \gzuncompress($data);
break;
case 'deflate':
$decoded = \gzinflate($data);
break;
case 'gzip':
$decoded = \gzdecode($data);
break;
default:
$decoded = \gzdecode($data);
}

return $decoded;
if ($decoded === false) {
throw new CompressionException('gzip', 'The gz decompression function returned a false state while uncompressing the input data.');
}

return $decoded;
}
}
10 changes: 5 additions & 5 deletions src/Encoding/Base62x.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static function encode($input, $ibase = null)
// string
$ascidx = [];
$ascrlist = [];
$inputArr = \str_split($input);
$inputArr = \mb_str_split($input);
$inputlen = \count($inputArr);
//if(!isset($ascidx)){ $ascidx = array(); }
//if(!isset($ascrlist)){ $ascrlist = array(); }
Expand Down Expand Up @@ -235,7 +235,7 @@ public static function decode($input, $obase = null)
// string
$ascidx = [];
$ascrlist = [];
$inputArr = \str_split($input);
$inputArr = \mb_str_split($input);
$inputlen = \count($inputArr);
$setResult = self::setAscii($codetype, $inputArr, $ascidx, $ascmax, $asclist, $ascrlist);
$asctype = $setResult['asctype'];
Expand Down Expand Up @@ -321,7 +321,7 @@ public static function xx2dec($inum, $ibase, $ridx)
$ridx_in['z'] = 61;
$ridx = $ridx_in;
}
$iArr = \str_split($inum);
$iArr = \mb_str_split($inum);
$iArr = \array_reverse($iArr);
$arrLen = \count($iArr);
$xnum = 0;
Expand All @@ -338,7 +338,7 @@ public static function xx2dec($inum, $ibase, $ridx)
\error_log(__FILE__.": xxdec found out of radix:$tmpi for base:$ibase.\n");
$tmpi = $ibase - 1;
}
$onum = $onum + $tmpi * \pow($ibase, ($i - $xnum));
$onum = $onum + $tmpi * $ibase ** ($i - $xnum);
//error_log("\t".__FILE__.": xx2dec ibase:$ibase i:$i c:".$iArr[$i]." tmpi:$tmpi onum:$onum xnum:$xnum");
}
if (\mb_strpos($onum, 'E') !== false) {
Expand Down Expand Up @@ -504,4 +504,4 @@ private static function _decodeByLength($tmpArr, $op, $m)

return [$rtn = $op, $m];
}
}
}
7 changes: 4 additions & 3 deletions src/Encryption/Crypt.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
namespace Mfonte\Base62x\Encryption;

use Mfonte\Base62x\Exception\CryptException;
use Mfonte\Base62x\Encryption\Cipher\Decrypt;
use Mfonte\Base62x\Encryption\Cipher\Encrypt;
use Mfonte\Base62x\Encryption\Cypher\Decrypt;
use Mfonte\Base62x\Encryption\Cypher\Encrypt;

class Crypt
{
protected $method = 'aes-128-ctr'; // default cipher method if none supplied. see: http://php.net/openssl_get_cipher_methods for more.
// default cipher method if none supplied. see: http://php.net/openssl_get_cipher_methods for more.
protected $method = 'aes-128-ctr';

private $key;

Expand Down
2 changes: 1 addition & 1 deletion src/Encryption/Cypher/Bytes.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Mfonte\Base62x\Encryption\Cipher;
namespace Mfonte\Base62x\Encryption\Cypher;

class Bytes
{
Expand Down
2 changes: 1 addition & 1 deletion src/Encryption/Cypher/Decrypt.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Mfonte\Base62x\Encryption\Cipher;
namespace Mfonte\Base62x\Encryption\Cypher;

class Decrypt
{
Expand Down
2 changes: 1 addition & 1 deletion src/Encryption/Cypher/Encrypt.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Mfonte\Base62x\Encryption\Cipher;
namespace Mfonte\Base62x\Encryption\Cypher;

class Encrypt
{
Expand Down

0 comments on commit 71d9ee2

Please sign in to comment.