for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Support.php
*
* PHP version 5
* @category Dcrypt
* @package Dcrypt
* @author Michael Meyer (mmeyer2k) <[email protected]>
* @license http://opensource.org/licenses/MIT The MIT License (MIT)
* @link https://github.com/mmeyer2k/dcrypt
*/
namespace Dcrypt;
* Provides numeric data conversion helper functions.
* @link https://apigen.ci/github/mmeyer2k/dcrypt/namespace-Dcrypt.html
class Support
{
* Turns an integer into a 4 byte binary representation
* @param int $dec Integer to convert to binary
* @return string
protected static function dec2bin($dec)
return self::hex2bin(\str_pad(\dechex($dec), 8, '0', STR_PAD_LEFT));
}
* Reverses dec2bin
* @param string $bin Binary string to convert to decimal
protected static function bin2dec($bin)
return \hexdec(\bin2hex($bin));
* An internal hex2bin implementation for PHP 5.3
* @param string $hexstr
* @codeCoverageIgnore
protected static function hex2bin($hexstr)
if (\function_exists('hex2bin')) {
return \hex2bin($hexstr);
$n = \strlen($hexstr);
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
$a = "a"; $ab = "ab"; $abc = "abc";
will produce issues in the first and second line, while this second example
will produce no issues.
$sbin = '';
$i = 0;
while ($i < $n) {
$a = \substr($hexstr, $i, 2);
$c = \pack('H*', $a);
$sbin.= $c;
$i+=2;
return $sbin;
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.