Code Duplication    Length = 26-26 lines in 2 locations

packages/connection/src/class-manager.php 1 location

@@ 571-596 (lines=26) @@
568
	 * @param Integer $user_id the user identifier.
569
	 * @return Object the user object.
570
	 */
571
	public function get_connected_user_data( $user_id = null ) {
572
		if ( ! $user_id ) {
573
			$user_id = get_current_user_id();
574
		}
575
576
		$transient_key    = "jetpack_connected_user_data_$user_id";
577
		$cached_user_data = get_transient( $transient_key );
578
579
		if ( $cached_user_data ) {
580
			return $cached_user_data;
581
		}
582
583
		$xml = new \Jetpack_IXR_Client(
584
			array(
585
				'user_id' => $user_id,
586
			)
587
		);
588
		$xml->query( 'wpcom.getUser' );
589
		if ( ! $xml->isError() ) {
590
			$user_data = $xml->getResponse();
591
			set_transient( $transient_key, $xml->getResponse(), DAY_IN_SECONDS );
592
			return $user_data;
593
		}
594
595
		return false;
596
	}
597
598
	/**
599
	 * Returns a user object of the connection owner.

class.jetpack.php 1 location

@@ 1695-1720 (lines=26) @@
1692
	/**
1693
	 * Get the wpcom user data of the current|specified connected user.
1694
	 */
1695
	public static function get_connected_user_data( $user_id = null ) {
1696
		// TODO: remove in favor of Connection_Manager->get_connected_user_data
1697
		if ( ! $user_id ) {
1698
			$user_id = get_current_user_id();
1699
		}
1700
1701
		$transient_key = "jetpack_connected_user_data_$user_id";
1702
1703
		if ( $cached_user_data = get_transient( $transient_key ) ) {
1704
			return $cached_user_data;
1705
		}
1706
1707
		$xml = new Jetpack_IXR_Client(
1708
			array(
1709
				'user_id' => $user_id,
1710
			)
1711
		);
1712
		$xml->query( 'wpcom.getUser' );
1713
		if ( ! $xml->isError() ) {
1714
			$user_data = $xml->getResponse();
1715
			set_transient( $transient_key, $xml->getResponse(), DAY_IN_SECONDS );
1716
			return $user_data;
1717
		}
1718
1719
		return false;
1720
	}
1721
1722
	/**
1723
	 * Get the wpcom email of the current|specified connected user.