Skip to content

Commit 112606c

Browse files
Add odd hour schedule method (#44288)
* Add odd hour schedule method * Update ManagesFrequencies.php Co-authored-by: Taylor Otwell <[email protected]>
1 parent 2645b5d commit 112606c

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/Illuminate/Console/Scheduling/ManagesFrequencies.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,16 @@ public function hourlyAt($offset)
174174
return $this->spliceIntoPosition(1, $offset);
175175
}
176176

177+
/**
178+
* Schedule the event to run every odd hour.
179+
*
180+
* @return $this
181+
*/
182+
public function everyOddHour()
183+
{
184+
return $this->spliceIntoPosition(1, 0)->spliceIntoPosition(2, '1-23/2');
185+
}
186+
177187
/**
178188
* Schedule the event to run every two hours.
179189
*

tests/Console/Scheduling/FrequencyTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public function testOverrideWithHourly()
7979

8080
public function testHourly()
8181
{
82+
$this->assertSame('0 1-23/2 * * *', $this->event->everyOddHour()->getExpression());
8283
$this->assertSame('0 */2 * * *', $this->event->everyTwoHours()->getExpression());
8384
$this->assertSame('0 */3 * * *', $this->event->everyThreeHours()->getExpression());
8485
$this->assertSame('0 */4 * * *', $this->event->everyFourHours()->getExpression());

0 commit comments

Comments
 (0)