Ejemplo n.º 1
0
 /**
  * @param Number|string $value
  * @return Currency
  */
 public function setValue($value)
 {
     parent::setValue($value);
     if (preg_match('/^\\(.*\\)$/is', trim($value))) {
         $this->setNegative(true);
         $this->setRawValue('-' . $this->getValue());
     }
     return $this;
 }
Ejemplo n.º 2
0
 /**
  * @param $value
  * @return void
  */
 public function setValue($value)
 {
     parent::setValue($value);
     if (!$this->limitUp() instanceof Infinity && $this->getRealValue() > $this->limitUp()->getValue()) {
         $this->setDiff(bcsub($this->getRealValue(), $this->limitUp()->getValue(), $this->getPrecision()));
     } elseif (!$this->limitDown() instanceof Infinity && $this->getRealValue() < $this->limitDown()->getValue()) {
         $this->setDiff(bcsub($this->limitDown()->getValue(), $this->getRealValue(), $this->getPrecision()) * -1);
     } else {
         $this->setDiff(0);
     }
 }
Ejemplo n.º 3
0
 public function testComparisons()
 {
     $num = new Number(5);
     $this->assertTrue($num->isPositive());
     $this->assertFalse($num->isNegative());
     $this->assertFalse($num->isZero());
     $this->assertTrue($num->isGreater(4));
     $this->assertFalse($num->isLess(4));
     $this->assertTrue($num->isEqual(5));
     $num->setValue(0);
     $this->assertTrue($num->isZero());
     $this->assertFalse($num->isPositive());
     $this->assertFalse($num->isNegative());
 }