Code Duplication    Length = 22-26 lines in 2 locations

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

@@ 489-510 (lines=22) @@
486
	 *
487
	 * @return array|WP_Error
488
	 */
489
	public function parse_site_info_response( $service_response ) {
490
491
		/**
492
		 * If the service returned an error, we pass it on.
493
		 */
494
		if ( is_wp_error( $service_response ) ) {
495
			return $service_response;
496
		}
497
498
		/**
499
		 * Check if the service returned proper site information.
500
		 */
501
		if ( ! isset( $service_response->ID ) ) {
502
			return new WP_Error(
503
				'no_site_info',
504
				__( 'Invalid site information returned from remote.', 'jetpack' ),
505
				'No site ID present in the response.'
506
			);
507
		}
508
509
		return $service_response;
510
	}
511
512
	/**
513
	 * Fetch list of posts from the WordPress public API.
@@ 550-575 (lines=26) @@
547
	 *
548
	 * @return array|WP_Error
549
	 */
550
	public function parse_posts_response( $service_response ) {
551
552
		/**
553
		 * If the service returned an error, we pass it on.
554
		 */
555
		if ( is_wp_error( $service_response ) ) {
556
			return $service_response;
557
		}
558
559
		/**
560
		 * Check if the service returned proper posts array.
561
		 */
562
		if ( ! isset( $service_response->posts ) || ! is_array( $service_response->posts ) ) {
563
			return new WP_Error(
564
				'no_posts',
565
				__( 'No posts data returned by remote.', 'jetpack' ),
566
				'No posts information set in the returned data.'
567
			);
568
		}
569
570
		/**
571
		 * Format the posts to preserve storage space.
572
		 */
573
574
		return $this->format_posts_for_storage( $service_response );
575
	}
576
577
	/**
578
	 * Format the posts for better storage. Drop all the data that is not used.