Code Duplication    Length = 22-26 lines in 2 locations

modules/widgets/wordpress-post-widget.php 2 locations

@@ 305-326 (lines=22) @@
302
	 *
303
	 * @return array|WP_Error
304
	 */
305
	public function parse_site_info_response( $service_response ) {
306
307
		/**
308
		 * If the service returned an error, we pass it on.
309
		 */
310
		if ( is_wp_error( $service_response ) ) {
311
			return $service_response;
312
		}
313
314
		/**
315
		 * Check if the service returned proper site information.
316
		 */
317
		if ( ! isset( $service_response->ID ) ) {
318
			return new WP_Error(
319
				'no_site_info',
320
				__( 'Invalid site information returned from remote.', 'jetpack' ),
321
				'No site ID present in the response.'
322
			);
323
		}
324
325
		return $service_response;
326
	}
327
328
	/**
329
	 * Fetch list of posts from the WordPress public API.
@@ 366-391 (lines=26) @@
363
	 *
364
	 * @return array|WP_Error
365
	 */
366
	public function parse_posts_response( $service_response ) {
367
368
		/**
369
		 * If the service returned an error, we pass it on.
370
		 */
371
		if ( is_wp_error( $service_response ) ) {
372
			return $service_response;
373
		}
374
375
		/**
376
		 * Check if the service returned proper posts array.
377
		 */
378
		if ( ! isset( $service_response->posts ) || ! is_array( $service_response->posts ) ) {
379
			return new WP_Error(
380
				'no_posts',
381
				__( 'No posts data returned by remote.', 'jetpack' ),
382
				'No posts information set in the returned data.'
383
			);
384
		}
385
386
		/**
387
		 * Format the posts to preserve storage space.
388
		 */
389
390
		return $this->format_posts_for_storage( $service_response );
391
	}
392
393
	/**
394
	 * Format the posts for better storage. Drop all the data that is not used.