Code Duplication    Length = 9-10 lines in 3 locations

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

@@ 576-584 (lines=9) @@
573
	 *
574
	 * @return string|int Returns the ID of the connection owner or False if no connection owner found.
575
	 */
576
	public function get_connection_owner_id() {
577
		$user_token       = $this->get_access_token( self::CONNECTION_OWNER );
578
		$connection_owner = false;
579
		if ( $user_token && is_object( $user_token ) && isset( $user_token->external_user_id ) ) {
580
			$connection_owner = $user_token->external_user_id;
581
		}
582
583
		return $connection_owner;
584
	}
585
586
	/**
587
	 * Returns an array of user_id's that have user tokens for communicating with wpcom.
@@ 651-660 (lines=10) @@
648
	 *
649
	 * @return object|false False if no connection owner found.
650
	 */
651
	public function get_connection_owner() {
652
		$user_token = $this->get_access_token( self::CONNECTION_OWNER );
653
654
		$connection_owner = false;
655
		if ( $user_token && is_object( $user_token ) && isset( $user_token->external_user_id ) ) {
656
			$connection_owner = get_userdata( $user_token->external_user_id );
657
		}
658
659
		return $connection_owner;
660
	}
661
662
	/**
663
	 * Returns true if the provided user is the Jetpack connection owner.
@@ 669-677 (lines=9) @@
666
	 * @param Integer|Boolean $user_id the user identifier. False for current user.
667
	 * @return Boolean True the user the connection owner, false otherwise.
668
	 */
669
	public function is_connection_owner( $user_id = false ) {
670
		if ( ! $user_id ) {
671
			$user_id = get_current_user_id();
672
		}
673
674
		$user_token = $this->get_access_token( self::CONNECTION_OWNER );
675
676
		return $user_token && is_object( $user_token ) && isset( $user_token->external_user_id ) && $user_id === $user_token->external_user_id;
677
	}
678
679
	/**
680
	 * Connects the user with a specified ID to a WordPress.com user using the