Code Duplication    Length = 30-30 lines in 2 locations

includes/class-give-db-comments.php 1 location

@@ 158-187 (lines=30) @@
155
	 *
156
	 * @return bool|null|array
157
	 */
158
	public function get_comment_by( $comment_id = 0, $by = 'id' ) {
159
		/* @var WPDB $wpdb */
160
		global $wpdb;
161
		$comment = null;
162
163
		// Make sure $comment_id is int.
164
		$comment_id = absint( $comment_id );
165
166
		// Bailout.
167
		if ( empty( $comment_id ) ) {
168
			return null;
169
		}
170
171
		switch ( $by ) {
172
			case 'id':
173
				$comment = $wpdb->get_row(
174
					$wpdb->prepare(
175
						"SELECT * FROM $this->table_name WHERE comment_ID = %s LIMIT 1",
176
						$comment_id
177
					),
178
					ARRAY_A
179
				);
180
				break;
181
182
			default:
183
				$comment = apply_filters( "give_get_comment_by_{$by}", $comment, $comment_id );
184
		}
185
186
		return $comment;
187
	}
188
189
	/**
190
	 * Retrieve comments from the database.

includes/class-give-db-logs.php 1 location

@@ 148-177 (lines=30) @@
145
	 *
146
	 * @return bool|null|array
147
	 */
148
	public function get_log_by( $log_id = 0, $by = 'id' ) {
149
		/* @var WPDB $wpdb */
150
		global $wpdb;
151
		$log = null;
152
153
		// Make sure $log_id is int.
154
		$log_id = absint( $log_id );
155
156
		// Bailout.
157
		if ( empty( $log_id ) ) {
158
			return null;
159
		}
160
161
		switch ( $by ) {
162
			case 'id':
163
				$log = $wpdb->get_row(
164
					$wpdb->prepare(
165
						"SELECT * FROM $this->table_name WHERE ID = %s LIMIT 1",
166
						$log_id
167
					),
168
					ARRAY_A
169
				);
170
				break;
171
172
			default:
173
				$log = apply_filters( "give_get_log_by_{$by}", $log, $log_id );
174
		}
175
176
		return $log;
177
	}
178
179
	/**
180
	 * Retrieve logs from the database.