Some suggestion about logic error
Closed this issue · 0 comments
ScreamZ commented
here namespace ADesigns\CalendarBundle\Entity;
public function __construct($title, \DateTime $startDatetime, \DateTime $endDatetime = null, $allDay = false)
{
$this->title = $title;
$this->startDatetime = $startDatetime;
$this->setAllDay($allDay);
if ($endDatetime === null && $this->allDay === false) {
throw new \InvalidArgumentException("Must specify an event End DateTime if not an all day event.");
}
$this->endDatetime = $endDatetime;
}
why u set : $endDatetime = null, $allDay = false
Should be better if you make a allday = true or put a default endDateTime
If the user doesnt specify these parameters he gonna get an exception directly because he doesnt define a endDate for a non-allDay event
So why allow these parameters optionnal if they make an instant exception if they're not specify.
Make them necessary or change to a default endDate, or set allday true by default
Thanks :)