Code Duplication    Length = 33-35 lines in 2 locations

includes/admin/tools/data/class-give-tools-delete-test-donors.php 1 location

@@ 116-148 (lines=33) @@
113
	 *
114
	 * @return array|bool $data The data for the CSV file
115
	 */
116
	public function pre_fetch() {
117
		$donation_ids = array();
118
		$donor_ids    = array();
119
120
		// Check if the ajax request if running for the first time.
121
		if ( 1 === (int) $this->step ) {
122
			// Delete all the donation ids.
123
			$this->delete_option( $this->donation_key );
124
			// Delete all the donor ids.
125
			$this->delete_option( $this->donor_key );
126
127
			// Delete all the step and set to 'count' which if the first step in the process of deleting the donors.
128
			$this->update_option( $this->step_key, 'count' );
129
130
			// Delete tha page count of the step.
131
			$this->update_option( $this->step_on_key, '0' );
132
		} else {
133
			// Get the old donors list.
134
			$donor_ids = $this->get_option( $this->donor_key );
135
136
			// Get the old donation list.
137
			$donation_ids = $this->get_option( $this->donation_key );
138
		}
139
140
		// Get the step and check for it if it's on the first step( 'count' ) or not.
141
		$step = (int) $this->get_step();
142
		if ( 1 === $step ) {
143
			/**
144
			 * Will add or update the donation and donor data by running wp query.
145
			 */
146
			$this->count( $step, $donation_ids, $donor_ids );
147
		}
148
	}
149
150
	/**
151
	 * Will Update or Add the donation and donors ids in the with option table for there respected key.

includes/admin/tools/data/class-give-tools-delete-import-donors.php 1 location

@@ 152-186 (lines=35) @@
149
	 *
150
	 * @return void
151
	 */
152
	public function pre_fetch() {
153
		$donation_ids = array();
154
		$donor_ids    = array();
155
156
		// Check if the ajax request if running for the first time.
157
		if ( 1 === (int) $this->step ) {
158
159
			// Delete all the form ids.
160
			$this->delete_option( $this->form_key );
161
162
			// Delete all the donation ids.
163
			$this->delete_option( $this->donation_key );
164
165
			// Delete all the donor ids.
166
			$this->delete_option( $this->donor_key );
167
168
			// Delete all the step and set to 'count' which if the first step in the process of deleting the donors.
169
			$this->update_option( $this->step_key, 'count' );
170
171
			// Delete tha page count of the step.
172
			$this->update_option( $this->step_on_key, '0' );
173
		} else {
174
175
			// Get the old donors list.
176
			$donor_ids = $this->get_option( $this->donor_key );
177
178
			// Get the old donation list.
179
			$donation_ids = $this->get_option( $this->donation_key );
180
		}
181
182
		// Get the step and check for it if it's on the first step( 'count' ) or not.
183
		$step = (int) $this->get_step();
184
		if ( 1 === $step ) {
185
			/**
186
			 * Will add or update the donation and donor data by running wp query.
187
			 */
188
			$this->count( $step, $donation_ids, $donor_ids );
189
		}