Code Duplication    Length = 22-26 lines in 2 locations

modules/widgets/wordpress-post-widget/class.jetpack-display-posts-widget-base.php 2 locations

@@ 519-540 (lines=22) @@
516
	 *
517
	 * @return array|WP_Error
518
	 */
519
	public function parse_site_info_response( $service_response ) {
520
521
		/**
522
		 * If the service returned an error, we pass it on.
523
		 */
524
		if ( is_wp_error( $service_response ) ) {
525
			return $service_response;
526
		}
527
528
		/**
529
		 * Check if the service returned proper site information.
530
		 */
531
		if ( ! isset( $service_response->ID ) ) {
532
			return new WP_Error(
533
				'no_site_info',
534
				__( 'Invalid site information returned from remote.', 'jetpack' ),
535
				'No site ID present in the response.'
536
			);
537
		}
538
539
		return $service_response;
540
	}
541
542
	/**
543
	 * Fetch list of posts from the WordPress public API.
@@ 580-605 (lines=26) @@
577
	 *
578
	 * @return array|WP_Error
579
	 */
580
	public function parse_posts_response( $service_response ) {
581
582
		/**
583
		 * If the service returned an error, we pass it on.
584
		 */
585
		if ( is_wp_error( $service_response ) ) {
586
			return $service_response;
587
		}
588
589
		/**
590
		 * Check if the service returned proper posts array.
591
		 */
592
		if ( ! isset( $service_response->posts ) || ! is_array( $service_response->posts ) ) {
593
			return new WP_Error(
594
				'no_posts',
595
				__( 'No posts data returned by remote.', 'jetpack' ),
596
				'No posts information set in the returned data.'
597
			);
598
		}
599
600
		/**
601
		 * Format the posts to preserve storage space.
602
		 */
603
604
		return $this->format_posts_for_storage( $service_response );
605
	}
606
607
	/**
608
	 * Format the posts for better storage. Drop all the data that is not used.