Code Duplication    Length = 9-10 lines in 3 locations

packages/connection/src/class-manager.php 3 locations

@@ 558-566 (lines=9) @@
555
	 *
556
	 * @return string|int Returns the ID of the connection owner or False if no connection owner found.
557
	 */
558
	public function get_connection_owner_id() {
559
		$user_token       = $this->get_access_token( self::JETPACK_MASTER_USER );
560
		$connection_owner = false;
561
		if ( $user_token && is_object( $user_token ) && isset( $user_token->external_user_id ) ) {
562
			$connection_owner = $user_token->external_user_id;
563
		}
564
565
		return $connection_owner;
566
	}
567
568
	/**
569
	 * Returns an array of user_id's that have user tokens for communicating with wpcom.
@@ 633-642 (lines=10) @@
630
	 *
631
	 * @return object|false False if no connection owner found.
632
	 */
633
	public function get_connection_owner() {
634
		$user_token = $this->get_access_token( self::JETPACK_MASTER_USER );
635
636
		$connection_owner = false;
637
		if ( $user_token && is_object( $user_token ) && isset( $user_token->external_user_id ) ) {
638
			$connection_owner = get_userdata( $user_token->external_user_id );
639
		}
640
641
		return $connection_owner;
642
	}
643
644
	/**
645
	 * Returns true if the provided user is the Jetpack connection owner.
@@ 651-659 (lines=9) @@
648
	 * @param Integer|Boolean $user_id the user identifier. False for current user.
649
	 * @return Boolean True the user the connection owner, false otherwise.
650
	 */
651
	public function is_connection_owner( $user_id = false ) {
652
		if ( ! $user_id ) {
653
			$user_id = get_current_user_id();
654
		}
655
656
		$user_token = $this->get_access_token( self::JETPACK_MASTER_USER );
657
658
		return $user_token && is_object( $user_token ) && isset( $user_token->external_user_id ) && $user_id === $user_token->external_user_id;
659
	}
660
661
	/**
662
	 * Connects the user with a specified ID to a WordPress.com user using the