Code Duplication    Length = 14-14 lines in 2 locations

includes/forms/functions.php 2 locations

@@ 519-532 (lines=14) @@
516
 *
517
 * @return float $sales Average monthly sales
518
 */
519
function give_get_average_monthly_form_sales( $form_id = 0 ) {
520
	$sales        = give_get_form_sales_stats( $form_id );
521
	$release_date = get_post_field( 'post_date', $form_id );
522
523
	$diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) );
524
525
	$months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication
526
527
	if ( $months > 0 ) {
528
		$sales = ( $sales / $months );
529
	}
530
531
	return $sales;
532
}
533
534
535
/**
@@ 544-557 (lines=14) @@
541
 *
542
 * @return float $earnings Average monthly earnings
543
 */
544
function give_get_average_monthly_form_earnings( $form_id = 0 ) {
545
	$earnings     = give_get_form_earnings_stats( $form_id );
546
	$release_date = get_post_field( 'post_date', $form_id );
547
548
	$diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) );
549
550
	$months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication
551
552
	if ( $months > 0 ) {
553
		$earnings = ( $earnings / $months );
554
	}
555
556
	return $earnings < 0 ? 0 : $earnings;
557
}
558
559
560
/**