diff -r 000000000000 -r 4eba9c11703f web/Zend/Crypt/Math/BigInteger.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/Zend/Crypt/Math/BigInteger.php Mon Dec 13 18:29:26 2010 +0100 @@ -0,0 +1,117 @@ +_loadAdapter($extension); + } + + /** + * Redirect all public method calls to the wrapped extension object. + * + * @param string $methodName + * @param array $args + * @throws Zend_Crypt_Math_BigInteger_Exception + */ + public function __call($methodName, $args) + { + if(!method_exists($this->_math, $methodName)) { + require_once 'Zend/Crypt/Math/BigInteger/Exception.php'; + throw new Zend_Crypt_Math_BigInteger_Exception('invalid method call: ' . get_class($this->_math) . '::' . $methodName . '() does not exist'); + } + return call_user_func_array(array($this->_math, $methodName), $args); + } + + /** + * @param string $extension + * @throws Zend_Crypt_Math_BigInteger_Exception + */ + protected function _loadAdapter($extension = null) + { + if ($extension === null) { + if (extension_loaded('gmp')) { + $extension = 'gmp'; + //} elseif (extension_loaded('big_int')) { + // $extension = 'big_int'; + } else { + $extension = 'bcmath'; + } + } + if($extension == 'gmp' && extension_loaded('gmp')) { + require_once 'Zend/Crypt/Math/BigInteger/Gmp.php'; + $this->_math = new Zend_Crypt_Math_BigInteger_Gmp(); + //} elseif($extension == 'bigint' && extension_loaded('big_int')) { + // require_once 'Zend/Crypt_Math/BigInteger/Bigint.php'; + // $this->_math = new Zend_Crypt_Math_BigInteger_Bigint(); + } elseif ($extension == 'bcmath' && extension_loaded('bcmath')) { + require_once 'Zend/Crypt/Math/BigInteger/Bcmath.php'; + $this->_math = new Zend_Crypt_Math_BigInteger_Bcmath(); + } else { + require_once 'Zend/Crypt/Math/BigInteger/Exception.php'; + throw new Zend_Crypt_Math_BigInteger_Exception($extension . ' big integer precision math support not detected'); + } + } + +} \ No newline at end of file