Code Duplication    Length = 4-6 lines in 3 locations

_inc/lib/icalendar-reader.php 3 locations

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