Example #1
0
File: Row.php Project: sumvee/pivot
 public function get(Number\Integer $field)
 {
     if (false == isset($this->_data[$field->toNative()])) {
         throw new Exceptions\InvalidRowException();
     }
     return $this->_data[$field->toNative()];
 }
Example #2
0
 public function testToReal()
 {
     $integer = new Integer(5);
     $nativeReal = new Real(5);
     $real = $integer->toReal();
     $this->assertTrue($real->sameValueAs($nativeReal));
 }
 public static function fromInteger(IntVal $integer, $force = true)
 {
     if (!$force && $integer->lessThan(new Number(1))) {
         throw new ValueNotConvertibleException($integer);
     }
     return parent::fromInteger($integer, $force);
 }
Example #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);
 }
 /**
  * @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;
 }
Example #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);
 }
Example #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);
 }
Example #8
0
 /**
  * fromInteger.
  *
  * @param IntVal $integer
  *
  * @return static
  */
 public static function fromInteger(IntVal $integer)
 {
     return new static($integer->value());
 }