Skip to content

Commit e84fa83

Browse files
coderabbitaylorotwell
authored andcommitted
✨ Add twiceMonthly() to Console\Scheduling\ManagesFrequencies. (#19874)
1 parent 73f8da3 commit e84fa83

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/Illuminate/Console/Scheduling/ManagesFrequencies.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,22 @@ public function monthlyOn($day = 1, $time = '0:0')
273273
return $this->spliceIntoPosition(3, $day);
274274
}
275275

276+
/**
277+
* Schedule the event to run twice monthly.
278+
*
279+
* @param int $first
280+
* @param int $second
281+
* @return $this
282+
*/
283+
public function twiceMonthly($first = 1, $second = 16)
284+
{
285+
$days = $first.','.$second;
286+
287+
return $this->spliceIntoPosition(1, 0)
288+
->spliceIntoPosition(2, 0)
289+
->spliceIntoPosition(3, $days);
290+
}
291+
276292
/**
277293
* Schedule the event to run quarterly.
278294
*

tests/Console/Scheduling/FrequencyTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ public function testMonthlyOn()
5353
$this->assertEquals('0 15 4 * * *', $this->event->monthlyOn(4, '15:00')->getExpression());
5454
}
5555

56+
public function testTwiceMonthly()
57+
{
58+
$this->assertEquals('0 0 1,16 * * *', $this->event->twiceMonthly(1, 16)->getExpression());
59+
}
60+
5661
public function testMonthlyOnWithMinutes()
5762
{
5863
$this->assertEquals('15 15 4 * * *', $this->event->monthlyOn(4, '15:15')->getExpression());

0 commit comments

Comments
 (0)