Code Duplication    Length = 27-31 lines in 2 locations

packages/connection/src/Manager.php 1 location

@@ 806-836 (lines=31) @@
803
	 *
804
	 * @return string Assumed site creation date and time.
805
	 */
806
	public function get_assumed_site_creation_date() {
807
		$earliest_registered_users  = get_users(
808
			array(
809
				'role'    => 'administrator',
810
				'orderby' => 'user_registered',
811
				'order'   => 'ASC',
812
				'fields'  => array( 'user_registered' ),
813
				'number'  => 1,
814
			)
815
		);
816
		$earliest_registration_date = $earliest_registered_users[0]->user_registered;
817
818
		$earliest_posts = get_posts(
819
			array(
820
				'posts_per_page' => 1,
821
				'post_type'      => 'any',
822
				'post_status'    => 'any',
823
				'orderby'        => 'date',
824
				'order'          => 'ASC',
825
			)
826
		);
827
828
		// If there are no posts at all, we'll count only on user registration date.
829
		if ( $earliest_posts ) {
830
			$earliest_post_date = $earliest_posts[0]->post_date;
831
		} else {
832
			$earliest_post_date = PHP_INT_MAX;
833
		}
834
835
		return min( $earliest_registration_date, $earliest_post_date );
836
	}
837
838
	/**
839
	 * Adds the activation source string as a parameter to passed arguments.

class.jetpack.php 1 location

@@ 4450-4476 (lines=27) @@
4447
	 *
4448
	 * @return string Assumed site creation date and time.
4449
	 */
4450
	public static function get_assumed_site_creation_date() {
4451
		$earliest_registered_users = get_users( array(
4452
			'role'    => 'administrator',
4453
			'orderby' => 'user_registered',
4454
			'order'   => 'ASC',
4455
			'fields'  => array( 'user_registered' ),
4456
			'number'  => 1,
4457
		) );
4458
		$earliest_registration_date = $earliest_registered_users[0]->user_registered;
4459
4460
		$earliest_posts = get_posts( array(
4461
			'posts_per_page' => 1,
4462
			'post_type'      => 'any',
4463
			'post_status'    => 'any',
4464
			'orderby'        => 'date',
4465
			'order'          => 'ASC',
4466
		) );
4467
4468
		// If there are no posts at all, we'll count only on user registration date.
4469
		if ( $earliest_posts ) {
4470
			$earliest_post_date = $earliest_posts[0]->post_date;
4471
		} else {
4472
			$earliest_post_date = PHP_INT_MAX;
4473
		}
4474
4475
		return min( $earliest_registration_date, $earliest_post_date );
4476
	}
4477
4478
	public static function apply_activation_source_to_args( &$args ) {
4479
		list( $activation_source_name, $activation_source_keyword ) = get_option( 'jetpack_activation_source' );