src/DateRange.php
public static function combine(array $ranges)
    {
        $range = new static();

        foreach ($ranges as $cur_range) {
            $cur_start = $cur_range->after;
            $cur_end = $cur_range->before;

            if (is_null($range->before) || $cur_end->lt($range->before)) {
                $range->before = $cur_end;
            }

            if (is_null($range->after) || $cur_start->gt($range->after)) {
                $range->after = $cur_start;
            }
        }

        return $range;
    }
public static function combine(array $ranges)
    {
        $range = new static();

        foreach ($ranges as $cur_range) {
            $cur_start = $cur_range->after;
            $cur_end = $cur_range->before;

            if (is_null($range->before) || $cur_end->lt($range->before)) {
                $range->before = $cur_end;
            }

            if (is_null($range->after) || $cur_start->gt($range->after)) {
                $range->after = $cur_start;
            }
        }

        return $range;
    }
public static function combine ( array $ ranges ) { $ range = new static ( ) ; foreach ( $ ranges as $ cur_range ) { $ cur_start = $ cur_range -> after ; $ cur_end = $ cur_range -> before ; if ( is_null ( $ range -> before ) || $ cur_end -> lt ( $ range -> before ) ) { $ range -> before = $ cur_end ; } if ( is_null ( $ range -> after ) || $ cur_start -> gt ( $ range -> after ) ) { $ range -> after = $ cur_start ; } } return $ range ; }
Combines a collection of date ranges into a single date range.

@param DateRange[] $ranges

@return DateRange

@TODO Doesn't support open started or open ended ranges.
@TODO Doesn't support non-intersecting ranges.

@TODO Look at the possibility of implementing an "inersect" method instead.
Combines a collection of date ranges into a single date range .