diff --git a/src/Calculator.php b/src/Calculator.php index 70fcf9f..2835b71 100644 --- a/src/Calculator.php +++ b/src/Calculator.php @@ -69,6 +69,16 @@ public static function make(int|string|DateTimeInterface $date): ZodiacInterface return (new self())->zodiac($date); } + /** + * {@inheritdoc} + * + * @see CalculatorInterface::compare() + */ + public static function compare(ZodiacInterface $zodiac1, ZodiacInterface $zodiac2): float + { + return $zodiac1->compatibility($zodiac2); + } + /** * Normalze given date to Carbon object * diff --git a/src/Interfaces/CalculatorInterface.php b/src/Interfaces/CalculatorInterface.php index 900d9af..5df4423 100644 --- a/src/Interfaces/CalculatorInterface.php +++ b/src/Interfaces/CalculatorInterface.php @@ -15,4 +15,13 @@ interface CalculatorInterface * @return ZodiacInterface */ public static function zodiac(int|string|DateTimeInterface $date): ZodiacInterface; + + /** + * Calculate zodiac sign compatibility between given objects + * + * @param ZodiacInterface $zodiac1 + * @param ZodiacInterface $zodiac2 + * @return float + */ + public static function compare(ZodiacInterface $zodiac1, ZodiacInterface $zodiac2): float; } diff --git a/tests/CalculatorTest.php b/tests/CalculatorTest.php index a6e3878..12f0edb 100644 --- a/tests/CalculatorTest.php +++ b/tests/CalculatorTest.php @@ -138,4 +138,16 @@ public static function invalidZodiacDataProvider(): Generator '', ]; } + + public function testCompare(): void + { + $calculator = new Calculator(); + $result = $calculator->compare(new Aries(), new Leo()); + $this->assertIsFloat($result); + $this->assertTrue($result >= 0 && $result <= 1); + + $result = Calculator::compare(new Aries(), new Leo()); + $this->assertIsFloat($result); + $this->assertTrue($result >= 0 && $result <= 1); + } }