Code Duplication    Length = 28-31 lines in 2 locations

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

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