for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Recurrence\Constraint;
use Recurrence\Model\Recurrence;
/**
* Class ExcludeDaysOfWeekConstraint
* @package Recurrence\Constraint
*/
class ExcludeDaysOfWeekConstraint implements RecurrenceConstraintInterface
{
* @var array
private $excludedDays = [];
* @param array $excludedDays
public function __construct(array $excludedDays = [])
$this->excludedDays = array_unique($excludedDays);
sort($this->excludedDays);
if (count($this->excludedDays) >= 7) {
throw new \InvalidArgumentException('At least one day of the week must be allowed');
}
* @param Recurrence $recurrence
* @param \Datetime $datetime
* @return \Datetime
public function apply(Recurrence $recurrence, \Datetime $datetime)
while (in_array((int) $datetime->format('N'), $this->excludedDays)) {
$datetime->modify('+1 day');
return $datetime;