I have a base class called BaseRecurring
.
It has a protected function called _checkCurrentMonth
Inside the _checkCurrentMonth
,
My code inside the BaseRecurring
class is
protected function _checkNextMonth($type, $startDate = 1, $endDate = 1)
{
$incrementToFirstDay = $startDate - 1;
$incrementToLastDay = $endDate - 1;
$startDate = new \DateTime('first day of this month');
$endDate = new \DateTime('first day of next month');
if ($incrementToFirstDay > 0 || $incrementToLastDay > 0) {
// e.g. if we want to start on the 23rd of the month
// we get P22D
$incrementToFirstDay = sprintf('P%dD', $incrementToFirstDay);
$incrementToLastDay = sprintf('P%dD', $incrementToLastDay);
$startDate->add(new \DateInterval($incrementToFirstDay));
$endDate->add(new \DateInterval($incrementToLastDay));
}
$this->checkMonth($type, $startDate, $endDate);
}
The issue is that I don't want the base class to define the implementation for checkMonth
. I want the child class to implement checkMonth
method.
I intend to have an interface called CheckMonthInterface
that will explicitly state a method called checkMonth
.
So do I have the base class implement the CheckMonthInterface
and then keep that method empty?
or do I have the base class NOT implement the CheckMonthInterface
and then have the child class implement it?