src/MonthDay.php
public function withMonth(int $month) : MonthDay
    {
        if ($month === $this->month) {
            return $this;
        }

        Field\MonthOfYear::check($month);

        $lastDay = Field\MonthOfYear::getLength($month);

        return new MonthDay($month, ($lastDay < $this->day) ? $lastDay : $this->day);
    }
public function withMonth(int $month) : MonthDay
    {
        if ($month === $this->month) {
            return $this;
        }

        Field\MonthOfYear::check($month);

        $lastDay = Field\MonthOfYear::getLength($month);

        return new MonthDay($month, ($lastDay < $this->day) ? $lastDay : $this->day);
    }
public function withMonth ( int $ month ) : MonthDay { if ( $ month === $ this -> month ) { return $ this ; } Field \ MonthOfYear :: check ( $ month ) ; $ lastDay = Field \ MonthOfYear :: getLength ( $ month ) ; return new MonthDay ( $ month , ( $ lastDay < $ this -> day ) ? $ lastDay : $ this -> day ) ; }
Returns a copy of this MonthDay with the month-of-year altered.

If the day-of-month is invalid for the specified month, the day will
be adjusted to the last valid day-of-month.

@param int $month

@return MonthDay

@throws DateTimeException If the month is invalid.
Returns a copy of this MonthDay with the month - of - year altered .