public function withDateAtDayOfWeekInMonth(int $dayOfWeek, int $occurrence) : self
    {
        self::assertValidDayOfWeek($dayOfWeek);
        
        if ($occurrence < -5 || $occurrence === 0 || $occurrence > 5) {
            throw new \InvalidArgumentException("Invalid occurrence: $occurrence.");
        }
        
        $calendar = $this->createCalendar();
        
        // IntlCalendar uses Sunday as day 1 - convert that to Monday as day 1.
        if (++$dayOfWeek === 8) {
            $dayOfWeek = 1;
        }
        
        $calendar->set(\IntlCalendar::FIELD_DAY_OF_WEEK, $dayOfWeek);
        $calendar->set(\IntlCalendar::FIELD_DAY_OF_WEEK_IN_MONTH, $occurrence);
        
        return static::fromIntlCalendar($calendar);
    }
public function withDateAtDayOfWeekInMonth(int $dayOfWeek, int $occurrence) : self
    {
        self::assertValidDayOfWeek($dayOfWeek);
        
        if ($occurrence < -5 || $occurrence === 0 || $occurrence > 5) {
            throw new \InvalidArgumentException("Invalid occurrence: $occurrence.");
        }
        
        $calendar = $this->createCalendar();
        
        // IntlCalendar uses Sunday as day 1 - convert that to Monday as day 1.
        if (++$dayOfWeek === 8) {
            $dayOfWeek = 1;
        }
        
        $calendar->set(\IntlCalendar::FIELD_DAY_OF_WEEK, $dayOfWeek);
        $calendar->set(\IntlCalendar::FIELD_DAY_OF_WEEK_IN_MONTH, $occurrence);
        
        return static::fromIntlCalendar($calendar);
    }
public function withDateAtDayOfWeekInMonth ( int $ dayOfWeek , int $ occurrence ) : self { self :: assertValidDayOfWeek ( $ dayOfWeek ) ; if ( $ occurrence < - 5 || $ occurrence === 0 || $ occurrence > 5 ) { throw new \ InvalidArgumentException ( "Invalid occurrence: $occurrence." ) ; } $ calendar = $ this -> createCalendar ( ) ; // IntlCalendar uses Sunday as day 1 - convert that to Monday as day 1. if ( ++ $ dayOfWeek === 8 ) { $ dayOfWeek = 1 ; } $ calendar -> set ( \ IntlCalendar :: FIELD_DAY_OF_WEEK , $ dayOfWeek ) ; $ calendar -> set ( \ IntlCalendar :: FIELD_DAY_OF_WEEK_IN_MONTH , $ occurrence ) ; return static :: fromIntlCalendar ( $ calendar ) ; }
Returns a new instance with the date set to the specified instance of the week day in the current month.

For example, given Monday and 1, this would set the date to the first Monday of the month. Given Friday and 3,
it would set the day of week to the third Friday of the month.

Maximum occurrence is 5. Negative occurrences are allowed up to a maximum of -5, in which case the relevant
occurrence from the end of the month is used. For example, Friday, -2 would be the penultimate Friday of
the month.

0 is not a valid occurrence.

Note that if the occurrence exceeds the number of occurrences in the month the date will overflow (or underflow)
to the next (or previous) month. For example, if the 5th Monday of the month is required in a month with only
4 Mondays, the date will actually be the first Monday of the following month.

@param int $dayOfWeek  The day of the week where 1 is Monday.
@param int $occurrence

@return DateTime
Returns a new instance with the date set to the specified instance of the week day in the current month .