// If given date is a DateTime object; check if it falls in the weekend
if (get_class($date) === 'DateTime') {
if (in_array($date->format('w'), $this->weekend_days)) {
return false;
}
}
the condition fails for any subclasses of DateTime (like the very popular Carbon class) which needlessly limits your APIs scope. Please consider the instanceof operator to allow for classes that derive from DateTime.
Looking at
the condition fails for any subclasses of
DateTime
(like the very popular Carbon class) which needlessly limits your APIs scope. Please consider theinstanceof
operator to allow for classes that derive fromDateTime
.