Example #1
0
 /** @test */
 public function should_divide_two_numbers()
 {
     $command = new DivideCommand(new AnyNumber(54.91456), new AnyNumber(8), new PositiveNumber(5));
     $total = $command->run();
     $this->assertInstanceOf('PhilipBrown\\Math\\Number', $total);
     $this->assertEquals(6.86432, $total->value());
 }
Example #2
0
 /**
  * Divide two numbers
  *
  * @param mixed $left
  * @param mixed $right
  * @param mixed $scale
  * @return Number
  */
 public static function divide($left, $right, $scale = 0)
 {
     $left = new AnyNumber($left);
     $right = new AnyNumber($right);
     $scale = new PositiveNumber($scale);
     $command = new DivideCommand($left, $right, $scale);
     return $command->run();
 }