Skip to content

Commit

Permalink
Optimize code
Browse files Browse the repository at this point in the history
  • Loading branch information
olivervogel committed Nov 11, 2024
1 parent 598b0a4 commit 607ea86
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Calculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,14 @@ public static function zodiac(int|string|DateTimeInterface $date): ZodiacInterfa
foreach ($calculator::ZODIAC_CLASSNAMES as $classname) {
try {
$zodiac = new $classname();
if ($date->isZodiac($zodiac)) {
return $zodiac->setTranslator($calculator->translator());
if (
($zodiac instanceof ZodiacInterface) &&
($zodiac instanceof TranslatableInterface) &&
$date->isZodiac($zodiac)
) {
$zodiac->setTranslator($calculator->translator());

return $zodiac;
}
} catch (InvalidFormatException | InvalidArgumentException) {
// try next zodiac
Expand Down

0 comments on commit 607ea86

Please sign in to comment.