From 5286ad4bd31496b8882da7349849b8cdd5e87933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Fri, 20 Dec 2024 11:20:09 +0100 Subject: [PATCH] Add validateMinute() --- .../Console/Scheduling/ValidatesFrequencies.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Illuminate/Console/Scheduling/ValidatesFrequencies.php b/src/Illuminate/Console/Scheduling/ValidatesFrequencies.php index 7da802d5487..dce673152d0 100644 --- a/src/Illuminate/Console/Scheduling/ValidatesFrequencies.php +++ b/src/Illuminate/Console/Scheduling/ValidatesFrequencies.php @@ -4,7 +4,7 @@ use InvalidArgumentException; -use const Illuminate\Support\Date\{DAYS_PER_WEEK, HOURS_PER_DAY, MONTHS_PER_YEAR}; +use const Illuminate\Support\Date\{DAYS_PER_WEEK, HOURS_PER_DAY, MINUTES_PER_HOUR, MONTHS_PER_YEAR}; trait ValidatesFrequencies { @@ -18,6 +18,16 @@ protected function validateHour(int $hour) } } + /** + * @param int $minute + */ + protected function validateMinute(int $minute) + { + if ($minute < 0 || $minute > MINUTES_PER_HOUR) { + throw new InvalidArgumentException('Minute cron expression component must be between 0 and '.MINUTES_PER_HOUR.". [$minute] given"); + } + } + /** * @param int $dayOfWeek */ @@ -44,7 +54,7 @@ protected function validateMonth(int $month) protected function validateDayOfMonth(int|string $dayOfMonth) { if (is_string($dayOfMonth)) { - return; + return; } if ($dayOfMonth < 0 || $dayOfMonth > 31) {