Code Duplication    Length = 9-10 lines in 3 locations

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

@@ 566-574 (lines=9) @@
563
	 *
564
	 * @return string|int Returns the ID of the connection owner or False if no connection owner found.
565
	 */
566
	public function get_connection_owner_id() {
567
		$user_token       = $this->get_access_token( self::JETPACK_MASTER_USER );
568
		$connection_owner = false;
569
		if ( $user_token && is_object( $user_token ) && isset( $user_token->external_user_id ) ) {
570
			$connection_owner = $user_token->external_user_id;
571
		}
572
573
		return $connection_owner;
574
	}
575
576
	/**
577
	 * Returns an array of user_id's that have user tokens for communicating with wpcom.
@@ 641-650 (lines=10) @@
638
	 *
639
	 * @return object|false False if no connection owner found.
640
	 */
641
	public function get_connection_owner() {
642
		$user_token = $this->get_access_token( self::JETPACK_MASTER_USER );
643
644
		$connection_owner = false;
645
		if ( $user_token && is_object( $user_token ) && isset( $user_token->external_user_id ) ) {
646
			$connection_owner = get_userdata( $user_token->external_user_id );
647
		}
648
649
		return $connection_owner;
650
	}
651
652
	/**
653
	 * Returns true if the provided user is the Jetpack connection owner.
@@ 659-667 (lines=9) @@
656
	 * @param Integer|Boolean $user_id the user identifier. False for current user.
657
	 * @return Boolean True the user the connection owner, false otherwise.
658
	 */
659
	public function is_connection_owner( $user_id = false ) {
660
		if ( ! $user_id ) {
661
			$user_id = get_current_user_id();
662
		}
663
664
		$user_token = $this->get_access_token( self::JETPACK_MASTER_USER );
665
666
		return $user_token && is_object( $user_token ) && isset( $user_token->external_user_id ) && $user_id === $user_token->external_user_id;
667
	}
668
669
	/**
670
	 * Connects the user with a specified ID to a WordPress.com user using the