Skip to content

Commit

Permalink
Add odd hour schedule method (#44288)
Browse files Browse the repository at this point in the history
* Add odd hour schedule method

* Update ManagesFrequencies.php

Co-authored-by: Taylor Otwell <[email protected]>
  • Loading branch information
victor-falcon and taylorotwell authored Sep 26, 2022
1 parent 2645b5d commit 112606c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Illuminate/Console/Scheduling/ManagesFrequencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,16 @@ public function hourlyAt($offset)
return $this->spliceIntoPosition(1, $offset);
}

/**
* Schedule the event to run every odd hour.
*
* @return $this
*/
public function everyOddHour()
{
return $this->spliceIntoPosition(1, 0)->spliceIntoPosition(2, '1-23/2');
}

/**
* Schedule the event to run every two hours.
*
Expand Down
1 change: 1 addition & 0 deletions tests/Console/Scheduling/FrequencyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public function testOverrideWithHourly()

public function testHourly()
{
$this->assertSame('0 1-23/2 * * *', $this->event->everyOddHour()->getExpression());
$this->assertSame('0 */2 * * *', $this->event->everyTwoHours()->getExpression());
$this->assertSame('0 */3 * * *', $this->event->everyThreeHours()->getExpression());
$this->assertSame('0 */4 * * *', $this->event->everyFourHours()->getExpression());
Expand Down

0 comments on commit 112606c

Please sign in to comment.