diff --git a/src/Handler/DescribeExpression.php b/src/Handler/DescribeExpression.php index a9c5c54..6871051 100644 --- a/src/Handler/DescribeExpression.php +++ b/src/Handler/DescribeExpression.php @@ -54,21 +54,21 @@ public function __invoke(): string } } - if ($minute !== null && count($minute) === 1 && $hour !== null && count($hour) === 1) { + if ($minute !== null && count($minute) === 1 && $hour !== null && count($hour) === 1 && $month === null) { $time = sprintf('%02d:%02d', $hour[0], $minute[0]); - if ($weekday !== null && count($weekday) === 1 && $day === null && $month === null) { - $dayName = self::WEEKDAY_NAMES[$weekday[0]] ?? 'Day ' . $weekday[0]; - return sprintf('Weekly on %s at %s', $dayName, $time); - } + if ($day === null) { + if ($weekday === null) { + return sprintf('Daily at %s', $time); + } - if ($day !== null && count($day) === 1 && $weekday === null && $month === null) { + if (count($weekday) === 1) { + $dayName = self::WEEKDAY_NAMES[$weekday[0]] ?? 'Day ' . $weekday[0]; + return sprintf('Weekly on %s at %s', $dayName, $time); + } + } elseif ($weekday === null && count($day) === 1) { return sprintf('Monthly on day %d at %s', $day[0], $time); } - - if ($day === null && $month === null && $weekday === null) { - return sprintf('Daily at %s', $time); - } } return 'Custom schedule';