adesigns / calendar-bundle

This bundle allows you to integrate the jQuery FullCalendar plugin into your Symfony2 application.
MIT License
97 stars 60 forks source link

Some suggestion about logic error #14

Closed ScreamZ closed 10 years ago

ScreamZ commented 10 years ago

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 :)