Пример #1
0
 /**
  * This constructor creates a new runtime exception.
  *
  * @access public
  * @param string $message                                   the error message
  * @param array $values                                     the value to be formatted
  * @param IInt32\Type $code                                  the exception code
  */
 public function __construct($message = '', array $values = null, IInt32\Type $code = null)
 {
     parent::__construct(empty($values) ? (string) $message : strtr((string) $message, $values), IInt32\Module::nvl($code)->unbox());
 }
Пример #2
0
 /**
  * This method returns a random number with the range of x and y.
  *
  * @access public
  * @static
  * @param IInt32\Type $x                                    the min operand
  * @param IInt32\Type $y                                    the max operand
  * @return IInt32\Type                                      the result
  */
 public static function random(IInt32\Type $x = null, IInt32\Type $y = null) : IInt32\Type
 {
     $x = IInt32\Module::nvl($x);
     $y = IInt32\Module::nvl($y, IInt32\Type::box(mt_getrandmax()));
     return IInt32\Type::box(mt_rand($x->unbox(), $y->unbox()));
 }
Пример #3
0
 /**
  * This method returns a random number with the range of x and y.
  *
  * @access public
  * @static
  * @param IInteger\Type $x                                  the min operand
  * @param IInt32\Type $y                                    the max operand
  * @return IInteger\Type                                    the result
  */
 public static function random(IInteger\Type $x = null, IInt32\Type $y = null) : IInteger\Type
 {
     return IInteger\Type::box(gmp_strval(gmp_random(IInt32\Module::nvl($y, IInt32\Type::one())->unbox())));
 }
Пример #4
0
 /**
  * This method tests the "nvl" method.
  */
 public function test_nvl()
 {
     $x = IInt32\Type::one();
     $y = IInt32\Type::zero();
     $z = IInt32\Module::nvl($x, $y);
     $this->assertInstanceOf('\\Saber\\Data\\IInt32\\Type', $z);
     $this->assertSame(1, $z->unbox());
     $z = IInt32\Module::nvl(null, $x);
     $this->assertInstanceOf('\\Saber\\Data\\IInt32\\Type', $z);
     $this->assertSame(1, $z->unbox());
     $z = IInt32\Module::nvl(null, null);
     $this->assertInstanceOf('\\Saber\\Data\\IInt32\\Type', $z);
     $this->assertSame(0, $z->unbox());
 }
Пример #5
0
 /**
  * This method returns the result of rounding this object's value.
  *
  * @access public
  * @static
  * @param IFloat\Type $x                                    the operand
  * @param IInt32\Type $precision                            the precision to use when rounding
  * @return IFloat\Type                                      the result
  */
 public static function round(IFloat\Type $x, IInt32\Type $precision = null) : IFloat\Type
 {
     return IFloat\Type::box(round($x->unbox(), IInt32\Module::nvl($precision)->unbox()));
 }