Пример #1
0
 public static function initBignum($how = NULL)
 {
     /* Check to see if PHP is running in a 32-bit environment and if so, 
        use GMP or BC Math if available. */
     if ($how === NULL) {
         if (self::$bignum != self::bigChoose) {
             // determination has already been made
             return self::$bignum;
         } else {
             if (PHP_INT_SIZE >= 8) {
                 self::$bignum = self::bigNative;
             } else {
                 if (function_exists("gmp_add")) {
                     self::$bignum = self::bigGMP;
                 } else {
                     if (function_exists("bcadd")) {
                         self::$bignum = self::bigBC;
                     } else {
                         self::$bignum = self::bigNot;
                     }
                 }
             }
         }
     } else {
         switch ($how) {
             case self::bigChoose:
                 self::$bignum = $how;
                 return self::initBignum();
             case self::bigNot:
                 break;
             case self::bigNative:
                 if (PHP_INT_SIZE < 8) {
                     throw new UUIDException("Bignum method is not available.", 801);
                 }
                 break;
             case self::bigGMP:
                 if (!function_exists("gmp_add")) {
                     throw new UUIDException("Bignum method is not available.", 801);
                 }
                 break;
             case self::bigBC:
                 if (!function_exists("bcadd")) {
                     throw new UUIDException("Bignum method is not available.", 801);
                 }
                 break;
             default:
                 throw new UUIDException("Bignum method not implemented.", 901);
         }
         self::$bignum = $how;
     }
     return self::$bignum;
 }