Code Duplication    Length = 19-19 lines in 2 locations

projects/packages/sync/src/class-rest-sender.php 1 location

@@ 120-138 (lines=19) @@
117
	 *
118
	 * @return WP_Error
119
	 */
120
	protected function get_buffer( $queue, $number_of_items ) {
121
		$start        = time();
122
		$max_duration = 5; // this will try to get the buffer.
123
124
		$buffer   = $queue->checkout( $number_of_items );
125
		$duration = time() - $start;
126
127
		while ( is_wp_error( $buffer ) && $duration < $max_duration ) {
128
			sleep( 2 );
129
			$duration = time() - $start;
130
			$buffer   = $queue->checkout( $number_of_items );
131
		}
132
133
		if ( false === $buffer ) {
134
			return new WP_Error( 'queue_size', 'The queue is empty and there is nothing to send', 400 );
135
		}
136
137
		return $buffer;
138
	}
139
140
}
141

projects/plugins/jetpack/json-endpoints/jetpack/class.jetpack-json-api-sync-endpoint.php 1 location

@@ 341-359 (lines=19) @@
338
		);
339
	}
340
341
	protected function get_buffer( $queue, $number_of_items ) {
342
		$start = time();
343
		$max_duration = 5; // this will try to get the buffer
344
345
		$buffer = $queue->checkout( $number_of_items );
346
		$duration = time() - $start;
347
348
		while( is_wp_error( $buffer ) && $duration < $max_duration ) {
349
			sleep( 2 );
350
			$duration = time() - $start;
351
			$buffer = $queue->checkout( $number_of_items );
352
		}
353
354
		if ( $buffer === false ) {
355
			return new WP_Error( 'queue_size', 'The queue is empty and there is nothing to send', 400 );
356
		}
357
358
		return $buffer;
359
	}
360
}
361
362
class Jetpack_JSON_API_Sync_Close_Endpoint extends Jetpack_JSON_API_Sync_Endpoint {