Exemplo n.º 1
0
 /** @test */
 public function should_compare_two_numbers()
 {
     $command = new CompareCommand(new AnyNumber(1.03), new AnyNumber(1.04), new PositiveNumber(2));
     $total = $command->run();
     $this->assertInstanceOf('PhilipBrown\\Math\\Number', $total);
     $this->assertEquals(-1, $total->value());
 }
Exemplo n.º 2
0
 /**
  * Compare two numbers
  *
  * @param mixed $left
  * @param mixed $right
  * @param mixed $scale
  * @return Number
  */
 public static function compare($left, $right, $scale = 0)
 {
     $left = new AnyNumber($left);
     $right = new AnyNumber($right);
     $scale = new PositiveNumber($scale);
     $command = new CompareCommand($left, $right, $scale);
     return $command->run();
 }