Code Duplication    Length = 4-6 lines in 3 locations

_inc/lib/icalendar-reader.php 3 locations

@@ 105-109 (lines=5) @@
102
		foreach ( $events as $event ) {
103
104
			$date_from_ics = strtotime( $event['DTSTART'] );
105
			if ( isset( $event['DTEND'] ) ) {
106
				$duration = strtotime( $event['DTEND'] ) - strtotime( $event['DTSTART'] );
107
			} else {
108
				$duration = 0;
109
			}
110
111
			if ( isset( $event['RRULE'] ) && $this->timezone->getName() && 8 != strlen( $event['DTSTART'] ) ) {
112
				try {
@@ 405-408 (lines=4) @@
402
						if ( 8 == strlen( $event['DTSTART'] ) ) {
403
							$event['DTSTART'] = date( 'Ymd', $next_start_timestamp );
404
							$event['DTEND'] = date( 'Ymd', strtotime( $event['DTSTART'] ) + $duration );
405
						} else {
406
							$event['DTSTART'] = date( 'Ymd\THis', $next_start_timestamp );
407
							$event['DTEND'] = date( 'Ymd\THis', strtotime( $event['DTSTART'] ) + $duration );
408
						}
409
410
						// Move recurring event date forward
411
						$recurring_event_date_start = $event['DTSTART'];
@@ 417-422 (lines=6) @@
414
415
				}
416
417
			} else {
418
				// Process normal events
419
				if ( strtotime( isset( $event['DTEND'] ) ? $event['DTEND'] : $event['DTSTART'] ) >= $current ) {
420
					$upcoming[] = $event;
421
				}
422
			}
423
		}
424
		return $upcoming;
425
	}