src/YearWeek.php
public function withWeek(int $week) : YearWeek
    {
        if ($week === $this->week) {
            return $this;
        }

        Field\WeekOfYear::check($week);

        $year = $this->year;

        if ($week === 53 && ! Field\WeekOfYear::is53WeekYear($year)) {
            $year++;
            $week = 1;
        }

        return new YearWeek($year, $week);
    }
public function withWeek(int $week) : YearWeek
    {
        if ($week === $this->week) {
            return $this;
        }

        Field\WeekOfYear::check($week);

        $year = $this->year;

        if ($week === 53 && ! Field\WeekOfYear::is53WeekYear($year)) {
            $year++;
            $week = 1;
        }

        return new YearWeek($year, $week);
    }
public function withWeek ( int $ week ) : YearWeek { if ( $ week === $ this -> week ) { return $ this ; } Field \ WeekOfYear :: check ( $ week ) ; $ year = $ this -> year ; if ( $ week === 53 && ! Field \ WeekOfYear :: is53WeekYear ( $ year ) ) { $ year ++ ; $ week = 1 ; } return new YearWeek ( $ year , $ week ) ; }
Returns a copy of this YearWeek with the week altered.

If the new week is 53 and the year does not have 53 weeks, week one of the following year is selected.

@param int $week

@return YearWeek

@throws DateTimeException If the week is not valid.
Returns a copy of this YearWeek with the week altered .