Code Duplication    Length = 4-6 lines in 3 locations

_inc/lib/icalendar-reader.php 3 locations

@@ 151-155 (lines=5) @@
148
		foreach ( $events as $event ) {
149
150
			$date_from_ics = strtotime( $event['DTSTART'] );
151
			if ( isset( $event['DTEND'] ) ) {
152
				$duration = strtotime( $event['DTEND'] ) - strtotime( $event['DTSTART'] );
153
			} else {
154
				$duration = 0;
155
			}
156
157
			if ( isset( $event['RRULE'] ) && $this->timezone->getName() && 8 != strlen( $event['DTSTART'] ) ) {
158
				try {
@@ 451-454 (lines=4) @@
448
						if ( 8 == strlen( $event['DTSTART'] ) ) {
449
							$event['DTSTART'] = date( 'Ymd', $next_start_timestamp );
450
							$event['DTEND'] = date( 'Ymd', strtotime( $event['DTSTART'] ) + $duration );
451
						} else {
452
							$event['DTSTART'] = date( 'Ymd\THis', $next_start_timestamp );
453
							$event['DTEND'] = date( 'Ymd\THis', strtotime( $event['DTSTART'] ) + $duration );
454
						}
455
456
						// Move recurring event date forward
457
						$recurring_event_date_start = $event['DTSTART'];
@@ 463-468 (lines=6) @@
460
461
				}
462
463
			} else {
464
				// Process normal events
465
				if ( strtotime( isset( $event['DTEND'] ) ? $event['DTEND'] : $event['DTSTART'] ) >= $current ) {
466
					$upcoming[] = $event;
467
				}
468
			}
469
		}
470
		return $upcoming;
471
	}