Пример #1
0
 /** @test */
 public function should_subtract_two_numbers()
 {
     $command = new SubtractCommand(new AnyNumber(15.8889), new AnyNumber(2.1237), new PositiveNumber(4));
     $total = $command->run();
     $this->assertInstanceOf('PhilipBrown\\Math\\Number', $total);
     $this->assertEquals(13.7652, $total->value());
 }
Пример #2
0
 /**
  * Subtract two numbers
  *
  * @param mixed $left
  * @param mixed $right
  * @param mixed $scale
  * @return Number
  */
 public static function subtract($left, $right, $scale = 0)
 {
     $left = new AnyNumber($left);
     $right = new AnyNumber($right);
     $scale = new PositiveNumber($scale);
     $command = new SubtractCommand($left, $right, $scale);
     return $command->run();
 }