Skip to content

Commit

Permalink
✨ Add twiceMonthly() to Console\Scheduling\ManagesFrequencies. (#19874)
Browse files Browse the repository at this point in the history
  • Loading branch information
coderabbi authored and taylorotwell committed Jul 3, 2017
1 parent 73f8da3 commit e84fa83
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Illuminate/Console/Scheduling/ManagesFrequencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,22 @@ public function monthlyOn($day = 1, $time = '0:0')
return $this->spliceIntoPosition(3, $day);
}

/**
* Schedule the event to run twice monthly.
*
* @param int $first
* @param int $second
* @return $this
*/
public function twiceMonthly($first = 1, $second = 16)
{
$days = $first.','.$second;

return $this->spliceIntoPosition(1, 0)
->spliceIntoPosition(2, 0)
->spliceIntoPosition(3, $days);
}

/**
* Schedule the event to run quarterly.
*
Expand Down
5 changes: 5 additions & 0 deletions tests/Console/Scheduling/FrequencyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ public function testMonthlyOn()
$this->assertEquals('0 15 4 * * *', $this->event->monthlyOn(4, '15:00')->getExpression());
}

public function testTwiceMonthly()
{
$this->assertEquals('0 0 1,16 * * *', $this->event->twiceMonthly(1, 16)->getExpression());
}

public function testMonthlyOnWithMinutes()
{
$this->assertEquals('15 15 4 * * *', $this->event->monthlyOn(4, '15:15')->getExpression());
Expand Down

0 comments on commit e84fa83

Please sign in to comment.