Code Duplication    Length = 28-31 lines in 2 locations

includes/class-give-donate-form.php 2 locations

@@ 1058-1085 (lines=28) @@
1055
	 *
1056
	 * @return float|false
1057
	 */
1058
	public function increase_earnings( $amount = 0, $payment_id = 0 ) {
1059
1060
		$earnings   = give_get_form_earnings_stats( $this->ID );
1061
1062
		/**
1063
		 * Modify the earning amount when increasing.
1064
		 *
1065
		 * @since 2.1
1066
		 *
1067
		 * @param float $amount     Earning amount.
1068
		 * @param int   $form_id    Donation form ID.
1069
		 * @param int   $payment_id Donation ID.
1070
		 */
1071
		$amount = apply_filters( 'give_increase_form_earnings_amount', $amount, $this->ID, $payment_id );
1072
1073
		$new_amount = $earnings + (float) $amount;
1074
1075
		if ( $this->update_meta( '_give_form_earnings', $new_amount ) ) {
1076
1077
			$this->earnings = $new_amount;
1078
1079
			return $this->earnings;
1080
1081
		}
1082
1083
		return false;
1084
1085
	}
1086
1087
	/**
1088
	 * Decrease the earnings by the given amount
@@ 1098-1128 (lines=31) @@
1095
	 *
1096
	 * @return float|false
1097
	 */
1098
	public function decrease_earnings( $amount, $payment_id = 0 ) {
1099
1100
		$earnings = give_get_form_earnings_stats( $this->ID );
1101
1102
		if ( $earnings > 0 ) {
1103
1104
			/**
1105
			 * Modify the earning value when decreasing it.
1106
			 *
1107
			 * @since 2.1
1108
			 *
1109
			 * @param float $amount     Earning amount.
1110
			 * @param int   $form_id    Donation Form ID.
1111
			 * @param int   $payment_id Donation ID.
1112
			 */
1113
			$amount = apply_filters( 'give_decrease_form_earnings_amount', $amount, $this->ID, $payment_id );
1114
1115
			// Only decrease if greater than zero
1116
			$new_amount = $earnings - (float) $amount;
1117
1118
			if ( $this->update_meta( '_give_form_earnings', $new_amount ) ) {
1119
				$this->earnings = $new_amount;
1120
1121
				return $this->earnings;
1122
			}
1123
1124
		}
1125
1126
		return false;
1127
1128
	}
1129
1130
	/**
1131
	 * Determine if donation form closed or not