Ejemplo n.º 1
0
Archivo: Row.php Proyecto: sumvee/pivot
 public function get(Number\Integer $field)
 {
     if (false == isset($this->_data[$field->toNative()])) {
         throw new Exceptions\InvalidRowException();
     }
     return $this->_data[$field->toNative()];
 }
Ejemplo n.º 2
0
 public function testToReal()
 {
     $integer = new Integer(5);
     $nativeReal = new Real(5);
     $real = $integer->toReal();
     $this->assertTrue($real->sameValueAs($nativeReal));
 }
Ejemplo n.º 3
0
 public static function fromInteger(IntVal $integer, $force = true)
 {
     if (!$force && $integer->lessThan(new Number(1))) {
         throw new ValueNotConvertibleException($integer);
     }
     return parent::fromInteger($integer, $force);
 }
Ejemplo n.º 4
0
 /**
  * fromInteger.
  *
  * @param IntVal $integer
  * @param bool   $force
  *
  * @return static
  */
 public static function fromInteger(IntVal $integer, $force = true)
 {
     if (!$force && $integer->lessThan(new Number(0))) {
         throw new ValueNotConvertibleException($integer);
     }
     $naturalValue = abs($integer->value());
     return new static($naturalValue);
 }
Ejemplo n.º 5
0
 /**
  * @param array $claims
  * @return Jwt
  */
 public function encode($claims)
 {
     $builder = clone $this->builder;
     foreach ($claims as $claim => $value) {
         $builder->set($claim, $value);
     }
     $dateTime = $this->clock->getDateTime();
     $time = $dateTime->getTimestamp();
     $jwt = $builder->setIssuedAt($time)->setExpiration($time + $this->exp->toNative())->setNotBefore($time + $this->nbf->toNative())->sign($this->signer, $this->key)->getToken();
     return $jwt;
 }
Ejemplo n.º 6
0
 /**
  * Returns a Natural object given a PHP native int as parameter.
  *
  * @param int $value
  */
 public function __construct($value)
 {
     $options = array('options' => array('min_range' => 0));
     $value = filter_var($value, FILTER_VALIDATE_INT, $options);
     if (false === $value) {
         throw new InvalidNativeArgumentException($value, array('int (>=0)'));
     }
     parent::__construct($value);
 }
Ejemplo n.º 7
0
 /**
  * fromReal.
  *
  * @param Real         $real
  * @param RoundingMode $roundingMode
  * @param bool         $force
  *
  * @return static
  */
 public static function fromReal(Real $real, RoundingMode $roundingMode = null, $force = true)
 {
     if (!$force && $real->lessThan(new Number(0))) {
         throw new ValueNotConvertibleException($real);
     }
     if (null === $roundingMode) {
         $roundingMode = RoundingMode::HALF_UP();
     }
     $naturalValue = abs(Integer::fromReal($real, $roundingMode)->value());
     return new static($naturalValue);
 }
Ejemplo n.º 8
0
 /**
  * fromInteger.
  *
  * @param IntVal $integer
  *
  * @return static
  */
 public static function fromInteger(IntVal $integer)
 {
     return new static($integer->value());
 }