public static function startDateCannotBeAfterEndDate(DateTime $startDate, DateTime $endDate) { return new static("Start date `{$startDate->format('Y-m-d')}` cannot be after end date `{$endDate->format('Y-m-d')}`."); }
public function __construct(DateTime $startDate, DateTime $endDate) { if ($startDate > $endDate) { throw InvalidPeriod::startDateCannotBeAfterEndDate($startDate, $endDate); } $this->startDate = $startDate; $this->endDate = $endDate; }