/** * Validates the constructed date * @return void * @throws \InvalidArgumentException */ protected function validate() { parent::validate(); $d = $this->getDay(); $m = $this->getMonth(); if ($d > static::$daysInMonth[$m - 1]) { if (!($m == 2 && $d == 29 && static::isLeapYear($this->getYear()))) { throw new InvalidArgumentException(); } } }
/** * Validates the constructed date. * * @throws InvalidDateException */ protected function validate() { parent::validate(); $d = $this->getDay(); $m = $this->getMonth(); if ($d > static::$daysInMonth[$m - 1]) { if (!($m == 12 && $d == 30 && $this->isInLeapYear())) { throw new InvalidDateException($this); } } }