diff --git a/src/BigInteger/Adapter/Bcmath.php b/src/BigInteger/Adapter/Bcmath.php index 848f544..eff1ce8 100644 --- a/src/BigInteger/Adapter/Bcmath.php +++ b/src/BigInteger/Adapter/Bcmath.php @@ -48,15 +48,15 @@ public function init($operand, $base = null) $base = 10; $operand = $m[1]; // octal - } else if (preg_match('#^(0[0-7]+)$#', $operand, $m)) { + } elseif (preg_match('#^(0[0-7]+)$#', $operand, $m)) { $base = 8; $operand = $m[1]; // hex - } else if (preg_match('#^(?:0x)?([0-9a-f]+)$#', strtolower($operand), $m)) { + } elseif (preg_match('#^(?:0x)?([0-9a-f]+)$#', strtolower($operand), $m)) { $base = 16; $operand = $m[1]; // scientific notation - } else if (preg_match('#^([1-9]?\.?[0-9]+)[eE]\+?([0-9]+)$#', $operand, $m)) { + } elseif (preg_match('#^([1-9]?\.?[0-9]+)[eE]\+?([0-9]+)$#', $operand, $m)) { $base = 10; $operand = bcmul($m[1], bcpow('10', $m[2])); } else { diff --git a/src/BigInteger/AdapterPluginManager.php b/src/BigInteger/AdapterPluginManager.php index 8d38614..543eac2 100644 --- a/src/BigInteger/AdapterPluginManager.php +++ b/src/BigInteger/AdapterPluginManager.php @@ -16,7 +16,7 @@ * Plugin manager implementation for BigInteger adapters. * * Enforces that adapters retrieved are instances of - * Adapter\AdapterInterface. Additionally, it registers a number of default + * Adapter\AdapterInterface. Additionally, it registers a number of default * adapters available. * * @category Zend @@ -27,7 +27,7 @@ class AdapterPluginManager extends AbstractPluginManager { /** * Default set of adapters - * + * * @var array */ protected $invokableClasses = array( @@ -39,8 +39,8 @@ class AdapterPluginManager extends AbstractPluginManager * Validate the plugin * * Checks that the adapter loaded is an instance of Adapter\AdapterInterface. - * - * @param mixed $plugin + * + * @param mixed $plugin * @return void * @throws Exception\RuntimeException if invalid */ diff --git a/src/Math.php b/src/Math.php index 0a3f8ae..6901950 100644 --- a/src/Math.php +++ b/src/Math.php @@ -43,7 +43,7 @@ public static function randBytes($length, $strong = false) if ($rand !== false && strlen($rand) === $length) { return $rand; } - } + } } if ($strong) { throw new Exception\RuntimeException( @@ -81,8 +81,8 @@ public static function rand($min, $max, $strong = false) ); } $log = log($range, 2); - $bytes = (int) ($log / 8) + 1; - $bits = (int) $log + 1; + $bytes = (int) ($log / 8) + 1; + $bits = (int) $log + 1; $filter = (int) (1 << $bits) - 1; do { $rnd = hexdec(bin2hex(self::randBytes($bytes, $strong))); diff --git a/test/BigInteger/Adapter/BcmathTest.php b/test/BigInteger/Adapter/BcmathTest.php index b5ca938..b6c35bd 100644 --- a/test/BigInteger/Adapter/BcmathTest.php +++ b/test/BigInteger/Adapter/BcmathTest.php @@ -26,7 +26,7 @@ class BcmathTest extends \PHPUnit_Framework_TestCase protected $adapter = null; protected $opts = array(); - + public function setUp() { if (!extension_loaded('bcmath')) { diff --git a/test/MathTest.php b/test/MathTest.php index bcfe93f..fc46ec7 100644 --- a/test/MathTest.php +++ b/test/MathTest.php @@ -26,8 +26,8 @@ public static function provideRandInt() array(2, 1, 10000, 100, 0.9, 1.1, false), array(2, 1, 10000, 100, 0.8, 1.2, true) ); - } - + } + public function testRandBytes() { for ($length=1; $length<4096; $length++) { @@ -36,16 +36,16 @@ public function testRandBytes() $this->assertEquals($length, strlen($rand)); } } - + /** * A Monte Carlo test that generates $cycles numbers from 0 to $tot - * and test if the numbers are above or below the line y=x with a + * and test if the numbers are above or below the line y=x with a * frequency range of [$min, $max] - * + * * Note: this code is inspired by the random number generator test * included in the PHP-CryptLib project of Anthony Ferrara * @see https://github.com/ircmaxell/PHP-CryptLib - * + * * @dataProvider provideRandInt */ public function testRandInt($num, $valid, $cycles, $tot, $min, $max, $strong) @@ -67,7 +67,7 @@ public function testRandInt($num, $valid, $cycles, $tot, $min, $max, $strong) $up++; } elseif ($x < $y) { $down++; - } + } } $this->assertGreaterThan(0, $up); $this->assertGreaterThan(0, $down); @@ -76,12 +76,12 @@ public function testRandInt($num, $valid, $cycles, $tot, $min, $max, $strong) $count++; } $i++; - } while ($i < $num && $count < $valid); + } while ($i < $num && $count < $valid); if ($count < $valid) { $this->fail('The random number generator failed the Monte Carlo test'); } } - + public function testRandBigInteger() { try {