Code Duplication    Length = 14-14 lines in 2 locations

includes/forms/functions.php 2 locations

@@ 570-583 (lines=14) @@
567
 *
568
 * @return float $sales Average monthly sales
569
 */
570
function give_get_average_monthly_form_sales( $form_id = 0 ) {
571
	$sales        = give_get_form_sales_stats( $form_id );
572
	$release_date = get_post_field( 'post_date', $form_id );
573
574
	$diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) );
575
576
	$months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication
577
578
	if ( $months > 0 ) {
579
		$sales = ( $sales / $months );
580
	}
581
582
	return $sales;
583
}
584
585
586
/**
@@ 595-608 (lines=14) @@
592
 *
593
 * @return float $earnings Average monthly earnings
594
 */
595
function give_get_average_monthly_form_earnings( $form_id = 0 ) {
596
	$earnings     = give_get_form_earnings_stats( $form_id );
597
	$release_date = get_post_field( 'post_date', $form_id );
598
599
	$diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) );
600
601
	$months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication
602
603
	if ( $months > 0 ) {
604
		$earnings = ( $earnings / $months );
605
	}
606
607
	return $earnings < 0 ? 0 : $earnings;
608
}
609
610
611
/**