Code Duplication    Length = 9-10 lines in 3 locations

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

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