/**
  * @test
  */
 public function I_can_create_it()
 {
     $minusOne = new NegativeNumberObject(-1);
     self::assertSame(-1, $minusOne->getValue());
     self::assertInstanceOf(NumberObject::getClass(), $minusOne);
     self::assertInstanceOf('\\Granam\\Number\\NegativeNumber', $minusOne);
     $floatMinusOne = new NegativeNumberObject(-1.0);
     self::assertSame(-1.0, $floatMinusOne->getValue());
     self::assertInstanceOf(NumberObject::getClass(), $floatMinusOne);
     self::assertInstanceOf('\\Granam\\Number\\NegativeNumber', $floatMinusOne);
     $zero = new NegativeNumberObject(0.0);
     self::assertSame(0.0, $zero->getValue());
     self::assertInstanceOf(NumberObject::getClass(), $zero);
     self::assertInstanceOf('\\Granam\\Number\\NegativeNumber', $zero);
 }
 /**
  * @test
  */
 public function I_can_create_it()
 {
     $twentyFive = new PositiveNumberObject(25);
     self::assertSame(25, $twentyFive->getValue());
     self::assertInstanceOf(NumberObject::getClass(), $twentyFive);
     self::assertInstanceOf('\\Granam\\Number\\PositiveNumber', $twentyFive);
     $twoHundredths = new PositiveNumberObject(0.02);
     self::assertSame(0.02, $twoHundredths->getValue());
     self::assertInstanceOf(NumberObject::getClass(), $twoHundredths);
     self::assertInstanceOf('\\Granam\\Number\\PositiveNumber', $twoHundredths);
     $zero = new PositiveNumberObject(-0.0);
     self::assertSame(0.0, $zero->getValue());
     self::assertInstanceOf(NumberObject::getClass(), $zero);
     self::assertInstanceOf('\\Granam\\Number\\PositiveNumber', $zero);
 }
 /**
  * @param mixed $value
  * @param bool $strict = false Accepts only explicit values, no null or empty string
  * @param bool $paranoid = false Throws exception if some value is lost on cast because of rounding
  * @throws \Granam\Number\Tools\Exceptions\WrongParameterType
  * @throws \Granam\Number\Tools\Exceptions\NegativeNumberCanNotBePositive
  * @throws \Granam\Scalar\Tools\Exceptions\WrongParameterType
  */
 public function __construct($value, $strict = true, $paranoid = false)
 {
     parent::__construct(ToNumber::toNegativeNumber($value), $strict, $paranoid);
 }
 /**
  * @return string
  */
 protected function getExternalRootNamespaces()
 {
     $numberClassReflection = new \ReflectionClass(NumberObject::getClass());
     return $numberClassReflection->getNamespaceName();
 }
 /**
  * @param mixed $value
  * @param bool $strict = true allows only explicit values, not null and empty string
  * @param bool $paranoid Throws exception if some value is lost on cast because of rounding
  * @throws \Granam\Float\Tools\Exceptions\WrongParameterType
  * @throws \Granam\Float\Tools\Exceptions\ValueLostOnCast
  */
 public function __construct($value, $strict = true, $paranoid = false)
 {
     parent::__construct(ToFloat::toFloat($value, $strict, $paranoid));
 }
 protected function getRootNamespace()
 {
     $rootReflection = new \ReflectionClass(NumberObject::getClass());
     return $rootReflection->getNamespaceName();
 }
 /**
  * @test
  */
 public function I_can_create_new_number_by_subtracting_value()
 {
     $number = new NumberObject(123);
     $decreased = $number->sub(456);
     self::assertSame(123, $number->getValue());
     self::assertSame(-333, $decreased->getValue());
     self::assertNotEquals($number, $decreased);
     $decreasedMore = $decreased->sub($decreased);
     // minus minus
     self::assertSame(0, $decreasedMore->getValue());
 }