Code Duplication    Length = 28-31 lines in 2 locations

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

@@ 1043-1070 (lines=28) @@
1040
	 *
1041
	 * @return float|false
1042
	 */
1043
	public function increase_earnings( $amount = 0, $payment_id = 0 ) {
1044
1045
		$earnings   = give_get_form_earnings_stats( $this->ID );
1046
1047
		/**
1048
		 * Modify the earning amount when increasing.
1049
		 *
1050
		 * @since 2.1
1051
		 *
1052
		 * @param float $amount     Earning amount.
1053
		 * @param int   $form_id    Donation form ID.
1054
		 * @param int   $payment_id Donation ID.
1055
		 */
1056
		$amount = apply_filters( 'give_increase_form_earnings_amount', $amount, $this->ID, $payment_id );
1057
1058
		$new_amount = $earnings + (float) $amount;
1059
1060
		if ( $this->update_meta( '_give_form_earnings', $new_amount ) ) {
1061
1062
			$this->earnings = $new_amount;
1063
1064
			return $this->earnings;
1065
1066
		}
1067
1068
		return false;
1069
1070
	}
1071
1072
	/**
1073
	 * Decrease the earnings by the given amount
@@ 1083-1113 (lines=31) @@
1080
	 *
1081
	 * @return float|false
1082
	 */
1083
	public function decrease_earnings( $amount, $payment_id = 0 ) {
1084
1085
		$earnings = give_get_form_earnings_stats( $this->ID );
1086
1087
		if ( $earnings > 0 ) {
1088
1089
			/**
1090
			 * Modify the earning value when decreasing it.
1091
			 *
1092
			 * @since 2.1
1093
			 *
1094
			 * @param float $amount     Earning amount.
1095
			 * @param int   $form_id    Donation Form ID.
1096
			 * @param int   $payment_id Donation ID.
1097
			 */
1098
			$amount = apply_filters( 'give_decrease_form_earnings_amount', $amount, $this->ID, $payment_id );
1099
1100
			// Only decrease if greater than zero
1101
			$new_amount = $earnings - (float) $amount;
1102
1103
			if ( $this->update_meta( '_give_form_earnings', $new_amount ) ) {
1104
				$this->earnings = $new_amount;
1105
1106
				return $this->earnings;
1107
			}
1108
1109
		}
1110
1111
		return false;
1112
1113
	}
1114
1115
	/**
1116
	 * Determine if donation form closed or not