Code Duplication    Length = 9-10 lines in 3 locations

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

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