Code Duplication    Length = 14-14 lines in 2 locations

includes/forms/functions.php 2 locations

@@ 511-524 (lines=14) @@
508
 *
509
 * @return float $sales Average monthly sales
510
 */
511
function give_get_average_monthly_form_sales( $form_id = 0 ) {
512
	$sales        = give_get_form_sales_stats( $form_id );
513
	$release_date = get_post_field( 'post_date', $form_id );
514
515
	$diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) );
516
517
	$months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication
518
519
	if ( $months > 0 ) {
520
		$sales = ( $sales / $months );
521
	}
522
523
	return $sales;
524
}
525
526
527
/**
@@ 536-549 (lines=14) @@
533
 *
534
 * @return float $earnings Average monthly earnings
535
 */
536
function give_get_average_monthly_form_earnings( $form_id = 0 ) {
537
	$earnings     = give_get_form_earnings_stats( $form_id );
538
	$release_date = get_post_field( 'post_date', $form_id );
539
540
	$diff = abs( current_time( 'timestamp' ) - strtotime( $release_date ) );
541
542
	$months = floor( $diff / ( 30 * 60 * 60 * 24 ) ); // Number of months since publication
543
544
	if ( $months > 0 ) {
545
		$earnings = ( $earnings / $months );
546
	}
547
548
	return $earnings < 0 ? 0 : $earnings;
549
}
550
551
552
/**