22 lines
541 B
PHP
22 lines
541 B
PHP
<?php
|
|
|
|
namespace DishPlanner\UserDish\Actions;
|
|
|
|
use App\Models\WeeklyRecurrence;
|
|
use DishPlanner\UserDish\Exceptions\InvalidRecurrenceTypeException;
|
|
use DishPlanner\UserDish\Interfaces\RecurrenceInterface;
|
|
|
|
class DeleteFixedRecurrenceAction
|
|
{
|
|
/**
|
|
* @throws InvalidRecurrenceTypeException
|
|
*/
|
|
public function execute(RecurrenceInterface $recurrence): void
|
|
{
|
|
if (! $recurrence instanceof WeeklyRecurrence) {
|
|
throw new InvalidRecurrenceTypeException();
|
|
}
|
|
|
|
$recurrence->delete();
|
|
}
|
|
}
|